Skip to content

Commit

Permalink
Merge pull request #58 from almaslennikov/resource-prefix-fix
Browse files Browse the repository at this point in the history
Drop validation for resource prefix
  • Loading branch information
adrianchiris authored Mar 29, 2022
2 parents 2a350bd + c00c4bf commit 872ea7b
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions pkg/resources/resources_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func (rm *resourceManager) ValidateConfigs() error {

for _, conf := range rm.configList {
// check if name contains acceptable characters
if !validResourceNameOrPrefix(conf.ResourceName) {
if !validResourceName(conf.ResourceName) {
return fmt.Errorf("error: resource name \"%s\" contains invalid characters", conf.ResourceName)
}
// check resource names are unique
Expand All @@ -129,11 +129,9 @@ func (rm *resourceManager) ValidateConfigs() error {
// resource name already exist
return fmt.Errorf("error: resource name \"%s\" already exists", conf.ResourceName)
}
// If prefix is not configured - use the default one. Otherwise validate if it contains acceptable characters
// If prefix is not configured - use the default one
if conf.ResourcePrefix == "" {
conf.ResourcePrefix = rm.defaultResourcePrefix
} else if !validResourceNameOrPrefix(conf.ResourcePrefix) {
return fmt.Errorf("error: resource prefix \"%s\" contains invalid characters", conf.ResourcePrefix)
}

if conf.RdmaHcaMax < 0 {
Expand Down Expand Up @@ -247,7 +245,7 @@ func (rm *resourceManager) RestartAllServers() error {
return nil
}

func validResourceNameOrPrefix(name string) bool {
func validResourceName(name string) bool {
// name regex
var validString = regexp.MustCompile(`^[a-zA-Z0-9_]+$`)
return validString.MatchString(name)
Expand Down

0 comments on commit 872ea7b

Please sign in to comment.