From c9901748e43d35b7a381b7d71b5e9a58e2ab3da6 Mon Sep 17 00:00:00 2001 From: Marcin Dobrochowski <39153236+anoipm@users.noreply.github.com> Date: Thu, 7 Dec 2023 15:32:51 +0100 Subject: [PATCH] remove runtime validation from webhook (#483) --- .../v1alpha2/function_validation.go | 10 ----- .../v1alpha2/function_validation_test.go | 37 ------------------- config/serverless/values.yaml | 6 +-- 3 files changed, 3 insertions(+), 50 deletions(-) diff --git a/components/serverless/pkg/apis/serverless/v1alpha2/function_validation.go b/components/serverless/pkg/apis/serverless/v1alpha2/function_validation.go index 6e1206867..f270f72df 100644 --- a/components/serverless/pkg/apis/serverless/v1alpha2/function_validation.go +++ b/components/serverless/pkg/apis/serverless/v1alpha2/function_validation.go @@ -44,7 +44,6 @@ type validationFunction func(*ValidationConfig) error func (fn *Function) getBasicValidations() []validationFunction { return []validationFunction{ fn.validateObjectMeta, - fn.Spec.validateRuntime, fn.Spec.validateLabels, fn.Spec.validateAnnotations, fn.Spec.validateSources, @@ -153,15 +152,6 @@ func (spec *FunctionSpec) validateGitAuthType(_ *ValidationConfig) error { } } -func (spec *FunctionSpec) validateRuntime(_ *ValidationConfig) error { - runtimeName := spec.Runtime - switch runtimeName { - case Python39, NodeJs16, NodeJs18: - return nil - } - return fmt.Errorf("spec.runtime contains unsupported value") -} - func (spec *FunctionSpec) validateSources(vc *ValidationConfig) error { sources := 0 if spec.Source.GitRepository != nil { diff --git a/components/serverless/pkg/apis/serverless/v1alpha2/function_validation_test.go b/components/serverless/pkg/apis/serverless/v1alpha2/function_validation_test.go index f89e28db5..f5234da63 100644 --- a/components/serverless/pkg/apis/serverless/v1alpha2/function_validation_test.go +++ b/components/serverless/pkg/apis/serverless/v1alpha2/function_validation_test.go @@ -135,43 +135,6 @@ func TestFunctionSpec_validateResources(t *testing.T) { }, expectedError: gomega.BeNil(), }, - "Should return error on unexpected runtime name": { - givenFunc: Function{ - ObjectMeta: metav1.ObjectMeta{Name: "test", Namespace: "test"}, - Spec: FunctionSpec{ - Runtime: "unknown-runtime-name", - Source: Source{ - Inline: &InlineSource{ - Source: "test-source", - }, - }, - }, - }, - expectedError: gomega.HaveOccurred(), - specifiedExpectedError: gomega.And( - gomega.ContainSubstring( - "spec.runtime", - ), - ), - }, - "Should return error on empty runtime name": { - givenFunc: Function{ - ObjectMeta: metav1.ObjectMeta{Name: "test", Namespace: "test"}, - Spec: FunctionSpec{ - Source: Source{ - Inline: &InlineSource{ - Source: "test-source", - }, - }, - }, - }, - expectedError: gomega.HaveOccurred(), - specifiedExpectedError: gomega.And( - gomega.ContainSubstring( - "spec.runtime", - ), - ), - }, "Should return error when more than one source is filled": { givenFunc: Function{ ObjectMeta: metav1.ObjectMeta{Name: "test", Namespace: "test"}, diff --git a/config/serverless/values.yaml b/config/serverless/values.yaml index cd242b35d..405fb7727 100644 --- a/config/serverless/values.yaml +++ b/config/serverless/values.yaml @@ -76,15 +76,15 @@ global: directory: "prod" function_controller: name: "function-controller" - version: "PR-482" + version: "PR-483" directory: "dev" function_webhook: name: "function-webhook" - version: "PR-482" + version: "PR-483" directory: "dev" function_build_init: name: "function-build-init" - version: "PR-482" + version: "PR-483" directory: "dev" function_registry_gc: name: "function-registry-gc"