remove sanitization (not needed)

This commit is contained in:
CamrynCarter
2026-08-13 18:37:29 -07:00
parent dffa91253e
commit abf9b7c6ab
2 changed files with 1 additions and 43 deletions
+1 -21
View File
@@ -182,7 +182,7 @@ func CreateManifestCmd(ctx context.Context, o *flags.CreateManifestOpts, s *stor
return fmt.Errorf("store contains no content to build a manifest from")
}
base := sanitizeName(filepath.Base(s.Root))
base := filepath.Base(s.Root)
output := o.Output
if output == "" {
@@ -287,23 +287,3 @@ func decodeOriginalChartRef(v string) (repoURL string, total string) {
}
return repoURL, total
}
// sanitizeName lowercases s and replaces any character outside [a-z0-9-] with '-' so
// the result is safe to use as a Kubernetes-style object name.
func sanitizeName(s string) string {
s = strings.ToLower(s)
var b strings.Builder
for _, r := range s {
switch {
case r >= 'a' && r <= 'z', r >= '0' && r <= '9', r == '-':
b.WriteRune(r)
default:
b.WriteRune('-')
}
}
out := strings.Trim(b.String(), "-")
if out == "" {
return "store"
}
return out
}
@@ -327,28 +327,6 @@ func TestCreateManifestCmd_MixedContent(t *testing.T) {
}
}
func TestSanitizeName(t *testing.T) {
tests := []struct {
name string
in string
want string
}{
{name: "already valid", in: "my-store", want: "my-store"},
{name: "uppercase lowered", in: "MyStore", want: "mystore"},
{name: "spaces and dots replaced", in: "my store.v1", want: "my-store-v1"},
{name: "leading and trailing separators trimmed", in: "--store--", want: "store"},
{name: "empty string falls back to store", in: "", want: "store"},
{name: "entirely invalid falls back to store", in: "***", want: "store"},
}
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
if got := sanitizeName(tc.in); got != tc.want {
t.Errorf("sanitizeName(%q) = %q, want %q", tc.in, got, tc.want)
}
})
}
}
func TestDecodeOriginalChartRef(t *testing.T) {
tests := []struct {
name string