Skip to content

Commit

Permalink
fix(slugification): kubernetes namespace and release name cannot cont…
Browse files Browse the repository at this point in the history
…ain dots

Signed-off-by: Alexey Igrychev <alexey.igrychev@flant.com>
  • Loading branch information
alexey-igrychev committed Apr 4, 2022
1 parent abffc62 commit e22eecb
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pkg/slug/slug.go
Expand Up @@ -148,12 +148,12 @@ func ValidateKubernetesNamespace(namespace string) error {
}

func validateKubernetesNamespace(name string) error {
errorMsgPrefix := fmt.Sprintf("kubernetes namespace should be a valid DNS-1123 subdomain")
errorMsgPrefix := fmt.Sprintf("kubernetes namespace should be a valid DNS-1123 label")
if len(name) == 0 {
return nil
} else if len(name) > kubernetesNamespaceMaxSize {
return fmt.Errorf("%s: %q is %d chars long", errorMsgPrefix, name, len(name))
} else if msgs := validation.IsDNS1123Subdomain(name); len(msgs) > 0 {
} else if msgs := validation.IsDNS1123Label(name); len(msgs) > 0 {
return fmt.Errorf("%s: %s", errorMsgPrefix, strings.Join(msgs, ", "))
}
return nil
Expand All @@ -171,12 +171,12 @@ func ValidateHelmRelease(name string) error {
}

func validateHelmRelease(name string) error {
errorMsgPrefix := fmt.Sprintf("helm release name should be a valid DNS-1123 subdomain and be maximum %d chars", helmReleaseMaxSize)
errorMsgPrefix := fmt.Sprintf("helm release name should be a valid DNS-1123 label and be maximum %d chars", helmReleaseMaxSize)
if len(name) == 0 {
return nil
} else if len(name) > helmReleaseMaxSize {
return fmt.Errorf("%s: %q is %d chars long", errorMsgPrefix, name, len(name))
} else if msgs := validation.IsDNS1123Subdomain(name); len(msgs) > 0 {
} else if msgs := validation.IsDNS1123Label(name); len(msgs) > 0 {
return fmt.Errorf("%s: %s", errorMsgPrefix, strings.Join(msgs, ", "))
}
return nil
Expand Down

0 comments on commit e22eecb

Please sign in to comment.