Skip to content

Commit

Permalink
remove runtime validation from webhook (#483)
Browse files Browse the repository at this point in the history
  • Loading branch information
anoipm authored Dec 7, 2023
1 parent 3612bf4 commit c990174
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
Expand Down
6 changes: 3 additions & 3 deletions config/serverless/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit c990174

Please sign in to comment.