fix(generation): fix the volume var/path name

Underscores are forbidden by Kubernetes (should be a valid URL string),
we replace "_" by "-" in names, and we leave the values file using the
original name. So a volume named "foo_bar" in compose file, is
registered as "foo_bar" in the values file, but "foo-bar" is used as
volume name in deployments, volume claims, ...
This commit is contained in:
2024-10-24 17:23:26 +02:00
parent db168c91c9
commit d72f371c59
3 changed files with 19 additions and 7 deletions

View File

@@ -117,6 +117,7 @@ func PathToName(path string) string {
path = strings.ReplaceAll(path, "_", "-")
path = strings.ReplaceAll(path, "/", "-")
path = strings.ReplaceAll(path, ".", "-")
path = strings.ToLower(path)
return path
}
@@ -192,3 +193,8 @@ func EncodeBasicYaml(data any) ([]byte, error) {
}
return buf.Bytes(), nil
}
// FixedResourceName returns a resource name without underscores to respect the kubernetes naming convention.
func FixedResourceName(name string) string {
return strings.ReplaceAll(name, "_", "-")
}