Skip to content

Commit

Permalink
TEP-0118: Apply PipelineTask Context Replacements in Matrix Include
Browse files Browse the repository at this point in the history
This commit updates replacement functionality for substituting context.pipelineTask with the specified values for matrix include parameters.

Note: This feature is still in preview mode.
  • Loading branch information
EmmaMunley authored and tekton-robot committed Mar 15, 2023
1 parent 4c40f01 commit a91c972
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 4 deletions.
3 changes: 3 additions & 0 deletions pkg/reconciler/pipelinerun/resources/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@ func ApplyPipelineTaskContexts(pt *v1beta1.PipelineTask) *v1beta1.PipelineTask {
pt.Params = replaceParamValues(pt.Params, replacements, map[string][]string{}, map[string]map[string]string{})
if pt.IsMatrixed() {
pt.Matrix.Params = replaceParamValues(pt.Matrix.Params, replacements, map[string][]string{}, map[string]map[string]string{})
for i := range pt.Matrix.Include {
pt.Matrix.Include[i].Params = replaceParamValues(pt.Matrix.Include[i].Params, replacements, map[string][]string{}, map[string]map[string]string{})
}
}
return pt
}
Expand Down
40 changes: 36 additions & 4 deletions pkg/reconciler/pipelinerun/resources/apply_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3260,7 +3260,15 @@ func TestApplyPipelineTaskContexts(t *testing.T) {
Params: []v1beta1.Param{{
Name: "retries",
Value: *v1beta1.NewStructuredValues("$(context.pipelineTask.retries)"),
}}},
}},
Include: []v1beta1.MatrixInclude{{
Name: "build-1",
Params: []v1beta1.Param{{
Name: "retries",
Value: *v1beta1.NewStructuredValues("$(context.pipelineTask.retries)"),
}},
}},
},
},
want: v1beta1.PipelineTask{
Retries: 5,
Expand All @@ -3272,7 +3280,15 @@ func TestApplyPipelineTaskContexts(t *testing.T) {
Params: []v1beta1.Param{{
Name: "retries",
Value: *v1beta1.NewStructuredValues("5"),
}}},
}},
Include: []v1beta1.MatrixInclude{{
Name: "build-1",
Params: []v1beta1.Param{{
Name: "retries",
Value: *v1beta1.NewStructuredValues("5"),
}},
}},
},
},
}, {
description: "context retries replacement with no defined retries",
Expand All @@ -3285,7 +3301,15 @@ func TestApplyPipelineTaskContexts(t *testing.T) {
Params: []v1beta1.Param{{
Name: "retries",
Value: *v1beta1.NewStructuredValues("$(context.pipelineTask.retries)"),
}}},
}},
Include: []v1beta1.MatrixInclude{{
Name: "build-1",
Params: []v1beta1.Param{{
Name: "retries",
Value: *v1beta1.NewStructuredValues("$(context.pipelineTask.retries)"),
}},
}},
},
},
want: v1beta1.PipelineTask{
Params: []v1beta1.Param{{
Expand All @@ -3296,7 +3320,15 @@ func TestApplyPipelineTaskContexts(t *testing.T) {
Params: []v1beta1.Param{{
Name: "retries",
Value: *v1beta1.NewStructuredValues("0"),
}}},
}},
Include: []v1beta1.MatrixInclude{{
Name: "build-1",
Params: []v1beta1.Param{{
Name: "retries",
Value: *v1beta1.NewStructuredValues("0"),
}},
}},
},
},
}} {
t.Run(tc.description, func(t *testing.T) {
Expand Down

0 comments on commit a91c972

Please sign in to comment.