From 98e4c6f17246da7af21572263a6a303a070a0613 Mon Sep 17 00:00:00 2001 From: Jawed khelil Date: Mon, 16 Sep 2024 16:20:44 +0200 Subject: [PATCH] fix ValidateStepResultsVariables to validate stepResults only --- pkg/apis/pipeline/v1/task_validation.go | 1 - .../pipeline/v1beta1/stepaction_validation_test.go | 13 ------------- 2 files changed, 14 deletions(-) diff --git a/pkg/apis/pipeline/v1/task_validation.go b/pkg/apis/pipeline/v1/task_validation.go index 4232d295d2b..d93fce54940 100644 --- a/pkg/apis/pipeline/v1/task_validation.go +++ b/pkg/apis/pipeline/v1/task_validation.go @@ -859,6 +859,5 @@ func ValidateStepResultsVariables(ctx context.Context, results []StepResult, scr resultsNames.Insert(r.Name) } errs = errs.Also(substitution.ValidateNoReferencesToUnknownVariables(script, "step.results", resultsNames).ViaField("script")) - errs = errs.Also(substitution.ValidateNoReferencesToUnknownVariables(script, "results", resultsNames).ViaField("script")) return errs } diff --git a/pkg/apis/pipeline/v1beta1/stepaction_validation_test.go b/pkg/apis/pipeline/v1beta1/stepaction_validation_test.go index 49efacdf91a..028fd7c2030 100644 --- a/pkg/apis/pipeline/v1beta1/stepaction_validation_test.go +++ b/pkg/apis/pipeline/v1beta1/stepaction_validation_test.go @@ -613,19 +613,6 @@ func TestStepActionSpecValidateError(t *testing.T) { Message: `windows script support requires "enable-api-fields" feature gate to be "alpha" but it is "beta"`, Paths: []string{}, }, - }, { - name: "step script refers to nonexistent result", - fields: fields{ - Image: "my-image", - Script: ` - #!/usr/bin/env bash - date | tee $(results.non-exist.path)`, - Results: []v1.StepResult{{Name: "a-result"}}, - }, - expectedError: apis.FieldError{ - Message: `non-existent variable in "\n\t\t\t#!/usr/bin/env bash\n\t\t\tdate | tee $(results.non-exist.path)"`, - Paths: []string{"script"}, - }, }, { name: "step script refers to nonexistent stepresult", fields: fields{