From 7d76471dcb680195789562beacd0affb9fb96e23 Mon Sep 17 00:00:00 2001 From: intojhanurag Date: Sat, 20 Dec 2025 21:25:49 +0000 Subject: [PATCH 1/3] validation added --- pkg/utils/names.go | 4 ++++ pkg/utils/names_test.go | 1 + 2 files changed, 5 insertions(+) diff --git a/pkg/utils/names.go b/pkg/utils/names.go index 40bfa04183..6582b93c38 100644 --- a/pkg/utils/names.go +++ b/pkg/utils/names.go @@ -34,6 +34,10 @@ type ErrInvalidNamespace error // (e.g. 'my-name', or 'abc-1', regex used for validation is '[a-z]([-a-z0-9]*[a-z0-9])?') func ValidateFunctionName(name string) error { + if strings.Contains(name, "--") { + return ErrInvalidFunctionName(errors.New(fmt.Sprintf("Function name '%v' cannot contain consecutive hyphens", name))) + } + if errs := validation.IsDNS1035Label(name); len(errs) > 0 { // In case of invalid name the error is this: // "a DNS-1035 label must consist of lower case alphanumeric characters or '-', diff --git a/pkg/utils/names_test.go b/pkg/utils/names_test.go index 82ef98d801..33890ab68a 100644 --- a/pkg/utils/names_test.go +++ b/pkg/utils/names_test.go @@ -26,6 +26,7 @@ func TestValidateFunctionName(t *testing.T) { {"Example", false}, {"EXAMPLE", false}, {"42", false}, + {"test--func", false}, } for _, c := range cases { From d59b9b61aad4448a20cf1a2a31eeca9aadd199a0 Mon Sep 17 00:00:00 2001 From: intojhanurag Date: Sat, 20 Dec 2025 21:34:25 +0000 Subject: [PATCH 2/3] linting issue --- pkg/utils/names.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/utils/names.go b/pkg/utils/names.go index 6582b93c38..91ce337334 100644 --- a/pkg/utils/names.go +++ b/pkg/utils/names.go @@ -35,7 +35,7 @@ type ErrInvalidNamespace error func ValidateFunctionName(name string) error { if strings.Contains(name, "--") { - return ErrInvalidFunctionName(errors.New(fmt.Sprintf("Function name '%v' cannot contain consecutive hyphens", name))) + return ErrInvalidFunctionName(fmt.Errorf("Function name '%v' cannot contain consecutive hyphens", name)) } if errs := validation.IsDNS1035Label(name); len(errs) > 0 { From dfca6c8faddc4cd5ff23b21899052c00018e0986 Mon Sep 17 00:00:00 2001 From: intojhanurag Date: Sat, 20 Dec 2025 21:37:32 +0000 Subject: [PATCH 3/3] linting issue --- pkg/utils/names.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/utils/names.go b/pkg/utils/names.go index 91ce337334..cfb77cbe94 100644 --- a/pkg/utils/names.go +++ b/pkg/utils/names.go @@ -35,7 +35,7 @@ type ErrInvalidNamespace error func ValidateFunctionName(name string) error { if strings.Contains(name, "--") { - return ErrInvalidFunctionName(fmt.Errorf("Function name '%v' cannot contain consecutive hyphens", name)) + return ErrInvalidFunctionName(fmt.Errorf("function name '%v' cannot contain consecutive hyphens", name)) } if errs := validation.IsDNS1035Label(name); len(errs) > 0 {