-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix stepaction param default value referencing other param
- multipass default value substitution: one for non referenced default values, another one for parameter references in default values - add validation to ensure parameters referenced in default values are defined before use - substitute default values of parameters with referenced parameter values if necessary - update replacementsFromStepResults to only process step result references - add comments which highlight order of hydration of parameters - add tests for replacementsFromStepResults, validateDefaultParameterReferences - add example for parameter references in default values of step action parameters Signed-off-by: Vibhav Bobade <[email protected]>
- Loading branch information
1 parent
0d698a7
commit ba4a742
Showing
5 changed files
with
542 additions
and
23 deletions.
There are no files selected for viewing
72 changes: 72 additions & 0 deletions
72
examples/v1/taskruns/beta/stepaction-param-references.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
apiVersion: tekton.dev/v1beta1 | ||
kind: StepAction | ||
metadata: | ||
name: step-action | ||
spec: | ||
params: | ||
- name: message | ||
default: "hello" | ||
- name: greeting | ||
default: "$(params.message) world" | ||
- name: values | ||
type: array | ||
default: | ||
- "first" | ||
- "second" | ||
- "third" | ||
- name: config | ||
properties: | ||
key1: | ||
type: string | ||
key2: | ||
type: string | ||
default: | ||
key1: "value1" | ||
key2: "value2" | ||
image: mirror.gcr.io/ubuntu | ||
env: | ||
- name: MESSAGE | ||
value: $(params.message) | ||
- name: GREETING | ||
value: $(params.greeting) | ||
- name: VALUE_1 | ||
value: $(params.values[0]) | ||
- name: VALUE_2 | ||
value: $(params.values[1]) | ||
- name: VALUE_3 | ||
value: $(params.values[2]) | ||
- name: CONFIG_KEY1 | ||
value: $(params.config.key1) | ||
- name: CONFIG_KEY2 | ||
value: $(params.config.key2) | ||
script: | | ||
#!/usr/bin/env bash | ||
echo "Message: ${MESSAGE}" | ||
echo "Greeting: ${GREETING}" | ||
echo "Values: ${VALUE_1}, ${VALUE_2}, ${VALUE_3}" | ||
echo "Config key1: ${CONFIG_KEY1}" | ||
echo "Config key2: ${CONFIG_KEY2}" | ||
--- | ||
apiVersion: tekton.dev/v1 | ||
kind: TaskRun | ||
metadata: | ||
generateName: param-reference-example- | ||
spec: | ||
taskSpec: | ||
steps: | ||
- name: show-params | ||
ref: | ||
name: step-action | ||
params: | ||
- name: message | ||
value: "hi" | ||
# greeting will use default with substituted message: "hi world" | ||
- name: values | ||
value: | ||
- "one" | ||
- "two" | ||
- "three" | ||
- name: config | ||
value: | ||
key1: "custom1" | ||
key2: "custom2" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.