Skip to content

Commit

Permalink
relax restrictions on workload name (#275)
Browse files Browse the repository at this point in the history
* relax restrictions on workload name

* allow hyphens

* display workload regex in failure message
  • Loading branch information
autodidaddict authored Jun 13, 2024
1 parent eac31ff commit fe15b9e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions control-api/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit fe15b9e

Please sign in to comment.