Skip to content

Commit

Permalink
fix: pipeline execution status test case index error
Browse files Browse the repository at this point in the history
  • Loading branch information
cugykw authored and tekton-robot committed Mar 19, 2024
1 parent 81ea62d commit da12202
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pkg/apis/pipeline/v1/pipeline_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ func validateExecutionStatusVariables(tasks []PipelineTask, finallyTasks []Pipel
// dag tasks cannot have param value as $(tasks.pipelineTask.status)
func validateExecutionStatusVariablesInTasks(tasks []PipelineTask) (errs *apis.FieldError) {
for idx, t := range tasks {
errs = errs.Also(t.validateExecutionStatusVariablesDisallowed()).ViaIndex(idx)
errs = errs.Also(t.validateExecutionStatusVariablesDisallowed().ViaIndex(idx))
}
return errs
}
Expand Down
19 changes: 19 additions & 0 deletions pkg/apis/pipeline/v1/pipeline_validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3534,6 +3534,25 @@ func TestPipelineTasksExecutionStatus(t *testing.T) {
Message: `invalid value: pipeline tasks can not refer to execution status of any other pipeline task or aggregate status of tasks`,
Paths: []string{"tasks[0].params[tasks-status].value"},
},
}, {
name: "invalid array variable in multi dag tasks accessing aggregate tasks status",
tasks: []PipelineTask{
{
Name: "foo",
TaskRef: &TaskRef{Name: "foo-task"},
Params: Params{{
Name: "tasks-status", Value: ParamValue{Type: ParamTypeArray, ArrayVal: []string{"$(tasks.status)"}},
}},
},
{
Name: "bar",
TaskRef: &TaskRef{Name: "foo-task"},
},
},
expectedError: apis.FieldError{
Message: `invalid value: pipeline tasks can not refer to execution status of any other pipeline task or aggregate status of tasks`,
Paths: []string{"tasks[0].params[tasks-status].value"},
},
}, {
name: "invalid string variable in finally accessing missing pipelineTask status",
finalTasks: []PipelineTask{{
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/pipeline/v1beta1/pipeline_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ func validateExecutionStatusVariables(tasks []PipelineTask, finallyTasks []Pipel
// dag tasks cannot have param value as $(tasks.pipelineTask.status)
func validateExecutionStatusVariablesInTasks(tasks []PipelineTask) (errs *apis.FieldError) {
for idx, t := range tasks {
errs = errs.Also(t.validateExecutionStatusVariablesDisallowed()).ViaIndex(idx)
errs = errs.Also(t.validateExecutionStatusVariablesDisallowed().ViaIndex(idx))
}
return errs
}
Expand Down
19 changes: 19 additions & 0 deletions pkg/apis/pipeline/v1beta1/pipeline_validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3577,6 +3577,25 @@ func TestPipelineTasksExecutionStatus(t *testing.T) {
Message: `invalid value: pipeline tasks can not refer to execution status of any other pipeline task or aggregate status of tasks`,
Paths: []string{"tasks[0].params[tasks-status].value"},
},
}, {
name: "invalid array variable in multi dag tasks accessing aggregate tasks status",
tasks: []PipelineTask{
{
Name: "foo",
TaskRef: &TaskRef{Name: "foo-task"},
Params: Params{{
Name: "tasks-status", Value: ParamValue{Type: ParamTypeArray, ArrayVal: []string{"$(tasks.status)"}},
}},
},
{
Name: "bar",
TaskRef: &TaskRef{Name: "foo-task"},
},
},
expectedError: apis.FieldError{
Message: `invalid value: pipeline tasks can not refer to execution status of any other pipeline task or aggregate status of tasks`,
Paths: []string{"tasks[0].params[tasks-status].value"},
},
}, {
name: "invalid string variable in finally accessing missing pipelineTask status",
finalTasks: []PipelineTask{{
Expand Down

0 comments on commit da12202

Please sign in to comment.