Skip to content

Commit

Permalink
Fix validation error on parameters 🐒
Browse files Browse the repository at this point in the history
When refactoring the validation code, I made a typo and called the
wrong function : prohibited instead of isolated.

Signed-off-by: Vincent Demeester <vdemeest@redhat.com>
  • Loading branch information
vdemeester authored and tekton-robot committed Oct 1, 2020
1 parent 1722db7 commit 5005e81
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 23 deletions.
2 changes: 1 addition & 1 deletion pkg/apis/pipeline/v1beta1/param_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,5 +165,5 @@ func validateStringVariableInTaskParameters(value, prefix string, stringVars set

func validateArrayVariableInTaskParameters(value, prefix string, stringVars sets.String, arrayVars sets.String) *apis.FieldError {
errs := substitution.ValidateVariableP(value, prefix, stringVars)
return errs.Also(substitution.ValidateVariableProhibitedP(value, prefix, arrayVars))
return errs.Also(substitution.ValidateVariableIsolatedP(value, prefix, arrayVars))
}
80 changes: 58 additions & 22 deletions pkg/apis/pipeline/v1beta1/pipelinerun_validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,34 +107,70 @@ func TestPipelineRun_Validate(t *testing.T) {
tests := []struct {
name string
pr v1beta1.PipelineRun
}{
{
name: "normal case",
pr: v1beta1.PipelineRun{
ObjectMeta: metav1.ObjectMeta{
Name: "pipelinelineName",
},
Spec: v1beta1.PipelineRunSpec{
PipelineRef: &v1beta1.PipelineRef{
Name: "prname",
},
}{{
name: "normal case",
pr: v1beta1.PipelineRun{
ObjectMeta: metav1.ObjectMeta{
Name: "pipelinelineName",
},
Spec: v1beta1.PipelineRunSpec{
PipelineRef: &v1beta1.PipelineRef{
Name: "prname",
},
},
}, {
name: "no timeout",
pr: v1beta1.PipelineRun{
ObjectMeta: metav1.ObjectMeta{
Name: "pipelinelineName",
},
}, {
name: "no timeout",
pr: v1beta1.PipelineRun{
ObjectMeta: metav1.ObjectMeta{
Name: "pipelinelineName",
},
Spec: v1beta1.PipelineRunSpec{
PipelineRef: &v1beta1.PipelineRef{
Name: "prname",
},
Spec: v1beta1.PipelineRunSpec{
PipelineRef: &v1beta1.PipelineRef{
Name: "prname",
},
Timeout: &metav1.Duration{Duration: 0},
Timeout: &metav1.Duration{Duration: 0},
},
},
}, {
name: "array param with pipelinespec and taskspec",
pr: v1beta1.PipelineRun{
ObjectMeta: metav1.ObjectMeta{
Name: "pipelinelineName",
},
Spec: v1beta1.PipelineRunSpec{
PipelineSpec: &v1beta1.PipelineSpec{
Params: []v1beta1.ParamSpec{{
Name: "pipeline-words",
Type: v1beta1.ParamTypeArray,
}},
Tasks: []v1beta1.PipelineTask{{
Name: "echoit",
Params: []v1beta1.Param{{
Name: "task-words",
Value: v1beta1.ArrayOrString{
ArrayVal: []string{"$(params.pipeline-words)"},
},
}},
TaskSpec: &v1beta1.EmbeddedTask{TaskSpec: &v1beta1.TaskSpec{
Params: []v1beta1.ParamSpec{{
Name: "task-words",
Type: v1beta1.ParamTypeArray,
}},
Steps: []v1beta1.Step{{
Container: corev1.Container{
Name: "echo",
Image: "ubuntu",
Command: []string{"echo"},
Args: []string{"$(params.task-words[*])"},
},
}},
}},
}},
},
},
},
}
}}

for _, ts := range tests {
t.Run(ts.name, func(t *testing.T) {
Expand Down

0 comments on commit 5005e81

Please sign in to comment.