-
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.
[TEP-0076] Add indexing into array for params
This commit provides the indexing into array for params and gated by alpha feature flag. Before this commit we can only refer to the whole array param, with this feature we can refer to array's element such as $(params.param-name[0]).
- Loading branch information
1 parent
5126d15
commit d3b8017
Showing
10 changed files
with
1,038 additions
and
1 deletion.
There are no files selected for viewing
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
58 changes: 58 additions & 0 deletions
58
examples/v1beta1/pipelineruns/alpha/pipelinerun-param-array-indexing.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,58 @@ | ||
apiVersion: tekton.dev/v1beta1 | ||
kind: Pipeline | ||
metadata: | ||
name: deploy | ||
spec: | ||
params: | ||
- name: environments | ||
type: array | ||
tasks: | ||
- name: deploy | ||
params: | ||
- name: environment1 | ||
value: '$(params.environments[0])' | ||
- name: environment2 | ||
value: '$(params.environments[1])' | ||
taskSpec: | ||
params: | ||
- name: environment1 | ||
type: string | ||
- name: environment2 | ||
type: string | ||
steps: | ||
# this step should echo "staging" | ||
- name: echo-params-1 | ||
image: bash:3.2 | ||
args: [ | ||
"echo", | ||
"$(params.environment1)", | ||
] | ||
# this step should echo "staging" | ||
- name: echo-params-2 | ||
image: ubuntu | ||
script: | | ||
#!/bin/bash | ||
VALUE=$(params.environment2) | ||
EXPECTED="qa" | ||
diff=$(diff <(printf "%s\n" "${VALUE[@]}") <(printf "%s\n" "${EXPECTED[@]}")) | ||
if [[ -z "$diff" ]]; then | ||
echo "Get expected: ${VALUE}" | ||
exit 0 | ||
else | ||
echo "Want: ${EXPECTED} Got: ${VALUE}" | ||
exit 1 | ||
fi | ||
--- | ||
apiVersion: tekton.dev/v1beta1 | ||
kind: PipelineRun | ||
metadata: | ||
name: deployrun | ||
spec: | ||
pipelineRef: | ||
name: deploy | ||
params: | ||
- name: environments | ||
value: | ||
- 'staging' | ||
- 'qa' | ||
- 'prod' |
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.