From c00c4bf2ad6bb4bc4937ebbcb4edc3a0a59186ee Mon Sep 17 00:00:00 2001 From: amaslennikov Date: Tue, 29 Mar 2022 11:52:24 +0300 Subject: [PATCH] Drop validation for resource prefix Strict validation such as for resource name (only numbers and symbols) should not apply for the resource prefix as it might contain different characters (e.g. "." in the domain name) --- pkg/resources/resources_manager.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/pkg/resources/resources_manager.go b/pkg/resources/resources_manager.go index f60b405..3226479 100644 --- a/pkg/resources/resources_manager.go +++ b/pkg/resources/resources_manager.go @@ -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 @@ -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 { @@ -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)