From 0c0f40e71410a5c9121d8fec1299e77aded4377c Mon Sep 17 00:00:00 2001 From: Chuang Wang Date: Fri, 15 Jul 2022 15:09:42 -0700 Subject: [PATCH] TEP-0075: Add examples with object params and results - 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. --- .../alpha/pipeline-object-param.yaml | 52 +++++++++++++++++++ .../taskruns/alpha/object-param-result.yaml | 36 +++++++++++++ 2 files changed, 88 insertions(+) create mode 100644 examples/v1beta1/pipelineruns/alpha/pipeline-object-param.yaml create mode 100644 examples/v1beta1/taskruns/alpha/object-param-result.yaml diff --git a/examples/v1beta1/pipelineruns/alpha/pipeline-object-param.yaml b/examples/v1beta1/pipelineruns/alpha/pipeline-object-param.yaml new file mode 100644 index 00000000000..d2f77a13fbd --- /dev/null +++ b/examples/v1beta1/pipelineruns/alpha/pipeline-object-param.yaml @@ -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 diff --git a/examples/v1beta1/taskruns/alpha/object-param-result.yaml b/examples/v1beta1/taskruns/alpha/object-param-result.yaml new file mode 100644 index 00000000000..0befcc0b4b1 --- /dev/null +++ b/examples/v1beta1/taskruns/alpha/object-param-result.yaml @@ -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)