Skip to content

Commit e9a11c3

Browse files
committed
Add support for params between Step and StepActions
Following the previous [PR](tektoncd#7317), which introduced Params to the `StepAction` CRD, this PR integrates `param` usage between `Steps` and `StepActions`. This completes support for params in `StepActions`. This work is part of issue tektoncd#7259.
1 parent e44cd73 commit e9a11c3

File tree

10 files changed

+930
-23
lines changed

10 files changed

+930
-23
lines changed
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
apiVersion: tekton.dev/v1alpha1
2+
kind: StepAction
3+
metadata:
4+
name: step-action
5+
spec:
6+
params:
7+
- name: string-param
8+
default: "a string param"
9+
- name: array-param
10+
type: array
11+
default:
12+
- an
13+
- array
14+
- param
15+
- name: object-param
16+
type: object
17+
properties:
18+
key1:
19+
type: string
20+
key2:
21+
type: string
22+
key3:
23+
type: string
24+
default:
25+
key1: "step-action default key1"
26+
key2: "step-action default key2"
27+
key3: "step-action default key3"
28+
image: bash:3.2
29+
args: [
30+
"echo",
31+
"$(params.array-param[*])",
32+
"$(params.string-param)",
33+
"$(params.object-param.key1)",
34+
"$(params.object-param.key2)"
35+
]
36+
---
37+
apiVersion: tekton.dev/v1
38+
kind: PipelineRun
39+
metadata:
40+
name: step-action-pipeline-run-propagated
41+
spec:
42+
params:
43+
- name: stringparam
44+
value: "pipelinerun stringparam"
45+
- name: arrayparam
46+
value:
47+
- "pipelinerun"
48+
- "array"
49+
- "param"
50+
- name: objectparam
51+
value:
52+
key2: "pipelinerun key2"
53+
PipelineSpec:
54+
tasks:
55+
- name: run-action
56+
taskSpec:
57+
steps:
58+
- name: action-runner
59+
ref:
60+
name: step-action
61+
params:
62+
- name: string-param
63+
value: $(params.stringparam)
64+
- name: array-param
65+
value: $(params.arrayparam[*])
66+
- name: object-param
67+
value: $(params.objectparam[*])
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
apiVersion: tekton.dev/v1alpha1
2+
kind: StepAction
3+
metadata:
4+
name: step-action
5+
spec:
6+
params:
7+
- name: string-param
8+
default: "a string param"
9+
- name: array-param
10+
type: array
11+
default:
12+
- an
13+
- array
14+
- param
15+
- name: object-param
16+
type: object
17+
properties:
18+
key1:
19+
type: string
20+
key2:
21+
type: string
22+
key3:
23+
type: string
24+
default:
25+
key1: "step-action default key1"
26+
key2: "step-action default key2"
27+
key3: "step-action default key3"
28+
image: bash:3.2
29+
args: [
30+
"echo",
31+
"$(params.array-param[*])",
32+
"$(params.string-param)",
33+
"$(params.object-param.key1)",
34+
"$(params.object-param.key2)",
35+
"$(params.object-param.key3)"
36+
]
37+
---
38+
apiVersion: tekton.dev/v1
39+
kind: TaskRun
40+
metadata:
41+
name: step-action-run
42+
spec:
43+
params:
44+
- name: stringparam
45+
value: "taskrun stringparam"
46+
- name: arrayparam
47+
value:
48+
- "taskrun"
49+
- "array"
50+
- "param"
51+
- name: objectparam
52+
value:
53+
key2: "taksrun key2"
54+
TaskSpec:
55+
params:
56+
- name: objectparam
57+
properties:
58+
key1:
59+
type: string
60+
key2:
61+
type: string
62+
default:
63+
key1: "taskspec default key1"
64+
key2: "taskspec default key2"
65+
steps:
66+
- name: action-runner
67+
ref:
68+
name: step-action
69+
params:
70+
- name: string-param
71+
value: $(params.stringparam)
72+
- name: array-param
73+
value: $(params.arrayparam[*])
74+
- name: object-param
75+
value: $(params.objectparam[*])

pkg/reconciler/pipelinerun/resources/apply.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -367,9 +367,9 @@ func propagateParams(t v1.PipelineTask, stringReplacements map[string]string, ar
367367
}
368368
}
369369
}
370-
t.TaskSpec.TaskSpec = *resources.ApplyReplacements(&t.TaskSpec.TaskSpec, stringReplacementsDup, arrayReplacementsDup)
370+
t.TaskSpec.TaskSpec = *resources.ApplyReplacements(&t.TaskSpec.TaskSpec, stringReplacementsDup, arrayReplacementsDup, objectReplacementsDup)
371371
} else {
372-
t.TaskSpec.TaskSpec = *resources.ApplyReplacements(&t.TaskSpec.TaskSpec, stringReplacements, arrayReplacements)
372+
t.TaskSpec.TaskSpec = *resources.ApplyReplacements(&t.TaskSpec.TaskSpec, stringReplacements, arrayReplacements, objectReplacements)
373373
}
374374
return t
375375
}
@@ -395,7 +395,7 @@ func PropagateResults(rpt *ResolvedPipelineTask, runStates PipelineRunState) {
395395
}
396396
}
397397
}
398-
rpt.ResolvedTask.TaskSpec = resources.ApplyReplacements(rpt.ResolvedTask.TaskSpec, stringReplacements, arrayReplacements)
398+
rpt.ResolvedTask.TaskSpec = resources.ApplyReplacements(rpt.ResolvedTask.TaskSpec, stringReplacements, arrayReplacements, map[string]map[string]string{})
399399
}
400400

401401
// ApplyTaskResultsToPipelineResults applies the results of completed TasksRuns and Runs to a Pipeline's

0 commit comments

Comments
 (0)