diff --git a/pkg/utils/names.go b/pkg/utils/names.go index 40bfa04183..cfb77cbe94 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(fmt.Errorf("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 {