Skip to content

Commit a91c972

Browse files
EmmaMunleytekton-robot
authored andcommitted
TEP-0118: Apply PipelineTask Context Replacements in Matrix Include
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.
1 parent 4c40f01 commit a91c972

File tree

2 files changed

+39
-4
lines changed

2 files changed

+39
-4
lines changed

pkg/reconciler/pipelinerun/resources/apply.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,9 @@ func ApplyPipelineTaskContexts(pt *v1beta1.PipelineTask) *v1beta1.PipelineTask {
161161
pt.Params = replaceParamValues(pt.Params, replacements, map[string][]string{}, map[string]map[string]string{})
162162
if pt.IsMatrixed() {
163163
pt.Matrix.Params = replaceParamValues(pt.Matrix.Params, replacements, map[string][]string{}, map[string]map[string]string{})
164+
for i := range pt.Matrix.Include {
165+
pt.Matrix.Include[i].Params = replaceParamValues(pt.Matrix.Include[i].Params, replacements, map[string][]string{}, map[string]map[string]string{})
166+
}
164167
}
165168
return pt
166169
}

pkg/reconciler/pipelinerun/resources/apply_test.go

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3260,7 +3260,15 @@ func TestApplyPipelineTaskContexts(t *testing.T) {
32603260
Params: []v1beta1.Param{{
32613261
Name: "retries",
32623262
Value: *v1beta1.NewStructuredValues("$(context.pipelineTask.retries)"),
3263-
}}},
3263+
}},
3264+
Include: []v1beta1.MatrixInclude{{
3265+
Name: "build-1",
3266+
Params: []v1beta1.Param{{
3267+
Name: "retries",
3268+
Value: *v1beta1.NewStructuredValues("$(context.pipelineTask.retries)"),
3269+
}},
3270+
}},
3271+
},
32643272
},
32653273
want: v1beta1.PipelineTask{
32663274
Retries: 5,
@@ -3272,7 +3280,15 @@ func TestApplyPipelineTaskContexts(t *testing.T) {
32723280
Params: []v1beta1.Param{{
32733281
Name: "retries",
32743282
Value: *v1beta1.NewStructuredValues("5"),
3275-
}}},
3283+
}},
3284+
Include: []v1beta1.MatrixInclude{{
3285+
Name: "build-1",
3286+
Params: []v1beta1.Param{{
3287+
Name: "retries",
3288+
Value: *v1beta1.NewStructuredValues("5"),
3289+
}},
3290+
}},
3291+
},
32763292
},
32773293
}, {
32783294
description: "context retries replacement with no defined retries",
@@ -3285,7 +3301,15 @@ func TestApplyPipelineTaskContexts(t *testing.T) {
32853301
Params: []v1beta1.Param{{
32863302
Name: "retries",
32873303
Value: *v1beta1.NewStructuredValues("$(context.pipelineTask.retries)"),
3288-
}}},
3304+
}},
3305+
Include: []v1beta1.MatrixInclude{{
3306+
Name: "build-1",
3307+
Params: []v1beta1.Param{{
3308+
Name: "retries",
3309+
Value: *v1beta1.NewStructuredValues("$(context.pipelineTask.retries)"),
3310+
}},
3311+
}},
3312+
},
32893313
},
32903314
want: v1beta1.PipelineTask{
32913315
Params: []v1beta1.Param{{
@@ -3296,7 +3320,15 @@ func TestApplyPipelineTaskContexts(t *testing.T) {
32963320
Params: []v1beta1.Param{{
32973321
Name: "retries",
32983322
Value: *v1beta1.NewStructuredValues("0"),
3299-
}}},
3323+
}},
3324+
Include: []v1beta1.MatrixInclude{{
3325+
Name: "build-1",
3326+
Params: []v1beta1.Param{{
3327+
Name: "retries",
3328+
Value: *v1beta1.NewStructuredValues("0"),
3329+
}},
3330+
}},
3331+
},
33003332
},
33013333
}} {
33023334
t.Run(tc.description, func(t *testing.T) {

0 commit comments

Comments
 (0)