From d12cd4280c08419ff5450d033c0edad473915a1d Mon Sep 17 00:00:00 2001 From: Georges Chaudy Date: Mon, 29 Jul 2024 15:54:52 +0200 Subject: [PATCH] unifiedStorage: name can be length 1 (#91126) * fix: name can be len 1 * fix: name can be len 1 * fix: name can be len 1 --- pkg/storage/unified/resource/validation.go | 2 +- pkg/storage/unified/resource/validation_test.go | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/storage/unified/resource/validation.go b/pkg/storage/unified/resource/validation.go index edb41ae745b..5ce5362717a 100644 --- a/pkg/storage/unified/resource/validation.go +++ b/pkg/storage/unified/resource/validation.go @@ -9,7 +9,7 @@ var validNameCharPattern = `a-zA-Z0-9\-\_\.` var validNamePattern = regexp.MustCompile(`^[` + validNameCharPattern + `]*$`).MatchString func validateName(name string) error { - if len(name) < 2 { + if len(name) == 0 { return fmt.Errorf("name is too short") } if len(name) > 64 { diff --git a/pkg/storage/unified/resource/validation_test.go b/pkg/storage/unified/resource/validation_test.go index 5ab0c2a3e75..9b4907d8630 100644 --- a/pkg/storage/unified/resource/validation_test.go +++ b/pkg/storage/unified/resource/validation_test.go @@ -13,6 +13,7 @@ func TestNameValidation(t *testing.T) { )) // OK + require.NoError(t, validateName("a")) require.NoError(t, validateName("hello-world")) require.NoError(t, validateName("hello.world")) require.NoError(t, validateName("hello_world"))