-
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.
Handle conditions in task result subsitution
(cherry picked from commit e939852) Had to remove usage of ConditionRegisterName from apply_test which hadn't been added in this release branch.
- Loading branch information
1 parent
acfeaad
commit 1e6f2fb
Showing
7 changed files
with
283 additions
and
8 deletions.
There are no files selected for viewing
110 changes: 110 additions & 0 deletions
110
examples/v1beta1/pipelineruns/pipeline-result-conditions.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,110 @@ | ||
apiVersion: tekton.dev/v1alpha1 | ||
kind: Condition | ||
metadata: | ||
name: condition-1 | ||
spec: | ||
check: | ||
args: | ||
- EXITCODE=$(python -c "import sys; input1=str.rstrip(sys.argv[1]); input2=str.rstrip(sys.argv[2]); print(0) if (input1 == 'heads') else | ||
print(1)" '$(params.flip-coin)' 'heads'); exit $EXITCODE | ||
command: | ||
- sh | ||
- -c | ||
image: python:alpine3.6 | ||
params: | ||
- name: flip-coin | ||
--- | ||
apiVersion: tekton.dev/v1beta1 | ||
kind: Task | ||
metadata: | ||
name: flip-coin | ||
spec: | ||
results: | ||
- description: /tmp/output | ||
name: output | ||
steps: | ||
- args: | ||
- python -c "import random; result = 'heads' if random.randint(0,1) == 0 else | ||
'tails'; result='heads'; print(result)" | tee $(results.output.path) | ||
command: | ||
- sh | ||
- -c | ||
image: python:alpine3.6 | ||
name: flip-coin | ||
--- | ||
apiVersion: tekton.dev/v1alpha1 | ||
kind: Task | ||
metadata: | ||
name: condition-check | ||
spec: | ||
params: | ||
- name: flip-coin | ||
results: | ||
- description: /tmp/output | ||
name: output | ||
steps: | ||
- args: | ||
- EXITCODE=$(python -c "import sys; input1=str.rstrip(sys.argv[1]); input2=str.rstrip(sys.argv[2]); print(input1) if (input1 == 'heads') else | ||
print(input1)" '$(params.flip-coin)' 'heads'); echo $EXITCODE | tee $(results.output.path) | ||
command: | ||
- sh | ||
- -c | ||
image: python:alpine3.6 | ||
--- | ||
apiVersion: tekton.dev/v1beta1 | ||
kind: Task | ||
metadata: | ||
name: generate-random-number | ||
spec: | ||
results: | ||
- description: /tmp/output | ||
name: output | ||
steps: | ||
- args: | ||
- python -c "import random; print(random.randint($0, $1))" | tee $2 | ||
- '0' | ||
- '9' | ||
- $(results.output.path) | ||
command: | ||
- sh | ||
- -c | ||
image: python:alpine3.6 | ||
name: generate-random-number | ||
--- | ||
apiVersion: tekton.dev/v1beta1 | ||
kind: Pipeline | ||
metadata: | ||
annotations: | ||
pipelines.kubeflow.org/pipeline_spec: '{"description": "Shows how to use dsl.Condition().", | ||
"name": "Conditional execution pipeline"}' | ||
name: flip-cond-gen-pipeline | ||
spec: | ||
params: [] | ||
tasks: | ||
- name: flip-coin | ||
params: [] | ||
taskRef: | ||
name: flip-coin | ||
- name: condition-check | ||
params: | ||
- name: flip-coin | ||
value: $(tasks.flip-coin.results.output) | ||
taskRef: | ||
name: condition-check | ||
- conditions: | ||
- conditionRef: condition-1 | ||
params: | ||
- name: flip-coin | ||
value: $(tasks.flip-coin.results.output) | ||
name: generate-random-number | ||
params: [] | ||
taskRef: | ||
name: generate-random-number | ||
--- | ||
apiVersion: tekton.dev/v1beta1 | ||
kind: PipelineRun | ||
metadata: | ||
name: flip-cond-gen-pipeline-run | ||
spec: | ||
pipelineRef: | ||
name: flip-cond-gen-pipeline |
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 |
---|---|---|
|
@@ -181,6 +181,7 @@ func (pt PipelineTask) Deps() []string { | |
} | ||
} | ||
} | ||
|
||
return deps | ||
} | ||
|
||
|
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