From fe15b9e3555046fd1bb7919fd53cc25d921d2fe7 Mon Sep 17 00:00:00 2001 From: Kevin Hoffman Date: Thu, 13 Jun 2024 10:28:58 -0400 Subject: [PATCH] relax restrictions on workload name (#275) * relax restrictions on workload name * allow hyphens * display workload regex in failure message --- control-api/run.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/control-api/run.go b/control-api/run.go index fa952509..501f3b52 100644 --- a/control-api/run.go +++ b/control-api/run.go @@ -48,8 +48,12 @@ type HostServicesConfiguration struct { NatsUserSeed string `json:"nats_user_seed"` } +const ( + workloadRegex = `^[a-zA-Z0-9_-]+$` +) + var ( - validWorkloadName = regexp.MustCompile(`^[a-z]+$`) + validWorkloadName = regexp.MustCompile(workloadRegex) ) // Creates a new deploy request based on the supplied options. Note that there is a fluent API function @@ -102,7 +106,7 @@ func (request *DeployRequest) Validate() (*jwt.GenericClaims, error) { request.DecodedClaims = *claims if !validWorkloadName.MatchString(claims.Subject) { - return nil, fmt.Errorf("workload name claim ('%s') does not match requirements of all lowercase letters", claims.Subject) + return nil, fmt.Errorf("workload name claim ('%s') does not match requirements (%s)", claims.Subject, workloadRegex) } var vr jwt.ValidationResults