Skip to content

Commit

Permalink
cleaning up examples to avoid writing to results using path
Browse files Browse the repository at this point in the history
We recommend to not use tekton reserved internal paths in scripts, specially,
for results. Our code base has a few examples which initializes the task
results using the reserved path /tekton/results/... instead of the
path variable i.e. $(results.myresult.path). Cleaning up examples to
include path variables while initializing the results.

Signed-off-by: pritidesai <[email protected]>
  • Loading branch information
pritidesai authored and tekton-robot committed Feb 1, 2023
1 parent 93151a3 commit ad60612
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 17 deletions.
1 change: 0 additions & 1 deletion examples/v1/pipelineruns/ignore-step-error.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ spec:
- image: alpine
name: verify-a-task-result
script: |
ls /tekton/results/
if [ $(params.task1-result) == 123 ]; then
echo "Yay! the task result matches which was initialized in the previous task while ignoring the step error"
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ spec:
image: alpine
script: |
if test -f $(workspaces.source.path)/$(params.path); then
printf yes | tee /tekton/results/exists
printf yes | tee $(results.exists.path)
else
printf no | tee /tekton/results/exists
printf no | tee $(results.exists.path)
fi
- name: echo-file-exists # when expression using task result, evaluates to true
when:
Expand Down
2 changes: 1 addition & 1 deletion examples/v1/pipelineruns/pipelinerun.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ spec:
workingDir: $(workspaces.source.path)
image: stedolan/jq
script: |
cat $(params.CONTEXT)/image-digested | jq '.[0].value' -rj | tee /tekton/results/IMAGE_DIGEST
cat $(params.CONTEXT)/image-digested | jq '.[0].value' -rj | tee $(results.IMAGE_DIGEST.path)
---
# This task deploys with kubectl apply -f <filename>
apiVersion: tekton.dev/v1
Expand Down
4 changes: 2 additions & 2 deletions examples/v1/taskruns/task-result.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ spec:
image: bash:latest
script: |
#!/usr/bin/env bash
date +%s | tee /tekton/results/current-date-unix-timestamp
date +%s | tee $(results.current-date-unix-timestamp.path)
- name: print-date-human-readable
image: bash:latest
script: |
#!/usr/bin/env bash
date | tee /tekton/results/current-date-human-readable
date | tee $(results.current-date-human-readable.path)
1 change: 0 additions & 1 deletion examples/v1beta1/pipelineruns/ignore-step-error.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ spec:
- image: alpine
name: verify-a-task-result
script: |
ls /tekton/results/
if [ $(params.task1-result) == 123 ]; then
echo "Yay! the task result matches which was initialized in the previous task while ignoring the step error"
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ spec:
image: alpine
script: |
if test -f $(workspaces.source.path)/$(params.path); then
printf yes | tee /tekton/results/exists
printf yes | tee $(results.exists.path)
else
printf no | tee /tekton/results/exists
printf no | tee $(results.exists.path)
fi
- name: echo-file-exists # when expression using task result, evaluates to true
when:
Expand Down
2 changes: 1 addition & 1 deletion examples/v1beta1/pipelineruns/pipelinerun.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ spec:
workingDir: $(workspaces.source.path)
image: stedolan/jq
script: |
cat $(params.CONTEXT)/image-digested | jq '.[0].value' -rj | tee /tekton/results/IMAGE_DIGEST
cat $(params.CONTEXT)/image-digested | jq '.[0].value' -rj | tee $(results.IMAGE_DIGEST.path)
---
# This task deploys with kubectl apply -f <filename>
apiVersion: tekton.dev/v1beta1
Expand Down
10 changes: 5 additions & 5 deletions examples/v1beta1/taskruns/alpha/large-task-result.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ spec:
image: bash:latest
script: |
#!/usr/bin/env bash
cat /dev/urandom | head -c 2500 | base64 | tee /tekton/results/result1 #about 1 K result
cat /dev/urandom | head -c 2500 | base64 | tee /tekton/results/result2 #about 4 K result
cat /dev/urandom | head -c 2500 | base64 | tee $(results.result1.path) #about 1 K result
cat /dev/urandom | head -c 2500 | base64 | tee $(results.result2.path) #about 4 K result
- name: step2
image: bash:latest
script: |
#!/usr/bin/env bash
cat /dev/urandom | head -c 2500 | base64 | tee /tekton/results/result3 #about 1 K result
cat /dev/urandom | head -c 2500 | base64 | tee /tekton/results/result4 #about 4 K result
cat /dev/urandom | head -c 2500 | base64 | tee /tekton/results/result5 #about 4 K result
cat /dev/urandom | head -c 2500 | base64 | tee $(results.result3.path) #about 1 K result
cat /dev/urandom | head -c 2500 | base64 | tee $(results.result4.path) #about 4 K result
cat /dev/urandom | head -c 2500 | base64 | tee $(results.result5.path) #about 4 K result
4 changes: 2 additions & 2 deletions examples/v1beta1/taskruns/task-result.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ spec:
image: bash:latest
script: |
#!/usr/bin/env bash
date +%s | tee /tekton/results/current-date-unix-timestamp
date +%s | tee $(results.current-date-unix-timestamp.path)
- name: print-date-human-readable
image: bash:latest
script: |
#!/usr/bin/env bash
date | tee /tekton/results/current-date-human-readable
date | tee $(results.current-date-human-readable.path)

0 comments on commit ad60612

Please sign in to comment.