-
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 taskrun params reference
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 for taskrun params, with this feature we can refer to array's element such as $(params.param-name[0]).
- Loading branch information
1 parent
895edb6
commit 32b01cf
Showing
8 changed files
with
715 additions
and
9 deletions.
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
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,37 @@ | ||
apiVersion: tekton.dev/v1beta1 | ||
kind: TaskRun | ||
metadata: | ||
name: params-array-indexing | ||
spec: | ||
params: | ||
- name: array-to-echo | ||
value: | ||
- "foo" | ||
- "bar" | ||
taskSpec: | ||
params: | ||
- name: array-to-echo | ||
type: array | ||
steps: | ||
# this step should echo "foo" | ||
- name: echo-params-1 | ||
image: bash:3.2 | ||
args: [ | ||
"echo", | ||
"$(params.array-to-echo[0])", | ||
] | ||
# this step should echo "bar" | ||
- name: echo-params-2 | ||
image: ubuntu | ||
script: | | ||
#!/bin/bash | ||
VALUE=$(params.array-to-echo[1]) | ||
EXPECTED="bar" | ||
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 |
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.