-
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-0048] Add support for default results
Today, a Task can declare a Result but not produce it and it's execution will still be successful whereas if a subsequent Task in a Pipeline attempts to use that Result it will fail. This behaviour can be confusing to the users as the Task which didn't produced the Result passed and the follow-up Task fails. Moreover, the user of the Task will loose faith in it as it failed to produce what it's claiming. This patch introduces the default results, ie, Task author can now add a default value to the results so that if their Task doesn't produce any result then the default value can be emitted. Now, with this change, if the Task author doesn't specifies any default value for the result and one of the step within that Task also doesn't produces it then the Task execution in whole will be marked as failed as it failed to prove it's contract.
- Loading branch information
Showing
26 changed files
with
616 additions
and
326 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
72 changes: 72 additions & 0 deletions
72
examples/v1beta1/pipelineruns/alpha/pipeline-emitting-default-results.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: PipelineRun | ||
metadata: | ||
name: pipelinerun-emit-default-results | ||
spec: | ||
pipelineSpec: | ||
tasks: | ||
- name: task1 | ||
taskSpec: | ||
results: | ||
- name: array-results | ||
type: array | ||
description: The array results | ||
default: | ||
- "1" | ||
- "2" | ||
- "3" | ||
steps: | ||
- name: write-array | ||
image: bash:latest | ||
script: | | ||
#!/usr/bin/env bash | ||
echo -n "this script won't emit array result" | ||
- name: task2 | ||
taskSpec: | ||
results: | ||
- name: object-results | ||
type: object | ||
description: The object results | ||
properties: | ||
foo: { type: string } | ||
hello: { type: string } | ||
default: | ||
foo: bar | ||
hello: world | ||
steps: | ||
- name: write-array | ||
image: bash:latest | ||
script: | | ||
#!/usr/bin/env bash | ||
echo -n "this script won't emit object result" | ||
results: | ||
- name: array-results | ||
type: array | ||
description: whole array | ||
value: $(tasks.task1.results.array-results[*]) | ||
- name: array-results-from-array-indexing-and-object-elements | ||
type: array | ||
description: whole array | ||
value: | ||
[ | ||
"$(tasks.task1.results.array-results[0])", | ||
"$(tasks.task2.results.object-results.foo)", | ||
] | ||
- name: array-indexing-results | ||
type: string | ||
description: array element | ||
value: $(tasks.task1.results.array-results[1]) | ||
- name: object-results | ||
type: object | ||
description: whole object | ||
value: $(tasks.task2.results.object-results[*]) | ||
- name: object-results-from-array-indexing-and-object-elements | ||
type: object | ||
description: whole object | ||
value: | ||
key1: $(tasks.task1.results.array-results[1]) | ||
key2: $(tasks.task2.results.object-results.hello) | ||
- name: object-element | ||
type: string | ||
description: object element | ||
value: $(tasks.task2.results.object-results.foo) |
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,33 @@ | ||
apiVersion: tekton.dev/v1beta1 | ||
kind: TaskRun | ||
metadata: | ||
generateName: default-result-run- | ||
spec: | ||
taskSpec: | ||
results: | ||
- name: result1 | ||
description: will be produced | ||
- name: string-result | ||
description: will not be produced by step but has default value | ||
default: "string value" | ||
- name: array-result | ||
description: default array result will be produced | ||
default: | ||
- "foo" | ||
- "bar" | ||
- name: eight-results | ||
type: object | ||
properties: | ||
IMAGE_URL: {type: string} | ||
IMAGE_DIGEST: {type: string} | ||
default: | ||
IMAGE_URL: "default.com" | ||
IMAGE_DIGEST: "defaultsha" | ||
steps: | ||
- name: failing-step | ||
onError: continue | ||
image: busybox | ||
script: | | ||
echo -n 123 | tee $(results.result1.path) | ||
exit 1 | ||
echo -n 456 | tee $(results.string-result.path) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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.