-
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-0075] Support Object Results substitution
This is part of work in TEP-0075. This commit provides the support to apply object results replacements. Previous this commit we support emitting object results so users can write object results to task level, but we cannot pass object results from one task to another within one pipeline. This commit adds the support for this.
- Loading branch information
1 parent
f93ff6f
commit dc9ea6c
Showing
7 changed files
with
185 additions
and
5 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
67 changes: 67 additions & 0 deletions
67
examples/v1beta1/pipelineruns/alpha/pipeline-object-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,67 @@ | ||
apiVersion: tekton.dev/v1beta1 | ||
kind: PipelineRun | ||
metadata: | ||
name: pipelinerun-object-results | ||
spec: | ||
pipelineSpec: | ||
tasks: | ||
- name: task1 | ||
taskSpec: | ||
results: | ||
- name: object-results | ||
type: object | ||
description: The object results | ||
properties: | ||
foo: | ||
type: string | ||
hello: | ||
type: string | ||
steps: | ||
- name: write-object | ||
image: bash:latest | ||
script: | | ||
#!/usr/bin/env bash | ||
echo -n "{\"foo\":\"bar\",\"hello\":\"world\"}" | tee $(results.object-results.path) | ||
- name: task2 | ||
params: | ||
- name: whole-object | ||
value: "$(tasks.task1.results.object-results[*])" | ||
- name: object-element | ||
value: "$(tasks.task1.results.object-results.hello)" | ||
taskSpec: | ||
params: | ||
- name: whole-object | ||
type: object | ||
properties: | ||
foo: | ||
type: string | ||
hello: | ||
type: string | ||
default: { | ||
hello: "", | ||
foo: "", | ||
} | ||
- name: object-element | ||
type: string | ||
default: "defaultparam1" | ||
steps: | ||
- name: print-object-foo | ||
image: bash:latest | ||
args: [ | ||
"echo", | ||
"$(params.whole-object.foo)" | ||
] | ||
- name: print-object-hello | ||
image: ubuntu | ||
script: | | ||
#!/bin/bash | ||
VALUE=$(params.object-element) | ||
EXPECTED="world" | ||
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
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