Skip to content

Commit

Permalink
TEP-0075: Add examples with object params and results
Browse files Browse the repository at this point in the history
- Added a taskrun level example that uses object param and
object result.

- Added a pipeline level example that uses individual variables of an
object param and uses the whole object param.
  • Loading branch information
chuangw6 authored and tekton-robot committed Jul 18, 2022
1 parent 8a7b0cf commit 0c0f40e
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 0 deletions.
52 changes: 52 additions & 0 deletions examples/v1beta1/pipelineruns/alpha/pipeline-object-param.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: mock-clone-task
spec:
params:
- name: arg
type: object
properties:
url:
type: string
commit:
type: string
steps:
- name: mock-clone-git
image: bash
args: [
"echo",
"--url=$(params.arg.url)",
"--commit=$(params.arg.commit)"
]
---
apiVersion: tekton.dev/v1beta1
kind: Pipeline
metadata:
name: mock-clone-pipeline
spec:
params:
- name: gitrepo
properties:
url: {}
commit: {}
tasks:
- name: mock-clone
params:
- name: arg
value: $(params.gitrepo[*])
taskRef:
name: mock-clone-task
---
apiVersion: tekton.dev/v1beta1
kind: PipelineRun
metadata:
generateName: pipelinerun-object-param-
spec:
params:
- name: gitrepo
value:
url: abc.com
commit: sha123
pipelineRef:
name: mock-clone-pipeline
36 changes: 36 additions & 0 deletions examples/v1beta1/taskruns/alpha/object-param-result.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
apiVersion: tekton.dev/v1beta1
kind: TaskRun
metadata:
generateName: object-param-result-
spec:
params:
- name: gitrepo
value:
url: "xyz.com"
commit: "sha123"
taskSpec:
params:
- name: gitrepo
type: object
properties:
url: {type: string}
commit: {type: string}
results:
- name: object-results
type: object
properties:
IMAGE_URL: {type: string}
IMAGE_DIGEST: {type: string}
steps:
- name: echo-object-params
image: bash
args: [
"echo",
"--url=$(params.gitrepo.url)",
"--commit=$(params.gitrepo.commit)"
]
- name: write-object-result
image: bash:latest
script: |
#!/usr/bin/env bash
echo -n "{\"IMAGE_URL\":\"ar.com\", \"IMAGE_DIGEST\":\"sha234\"}" > $(results.object-results.path)

0 comments on commit 0c0f40e

Please sign in to comment.