mirror of
https://github.com/hauler-dev/hauler.git
synced 2026-08-24 11:47:20 +00:00
remove sanitization (not needed)
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user