From 7ff3f78858d898b3717811b89b184fe3fd4c8c2d Mon Sep 17 00:00:00 2001 From: Jason Hall Date: Thu, 5 Dec 2019 17:04:46 -0500 Subject: [PATCH] Use script mode in even more examples --- examples/taskruns/build-gcs-targz.yaml | 2 +- examples/taskruns/build-gcs-zip.yaml | 2 +- examples/taskruns/build-push-kaniko.yaml | 2 -- examples/taskruns/cloud-event.yaml | 23 ++++------------- examples/taskruns/clustertask.yaml | 2 +- examples/taskruns/configmap.yaml | 7 +++--- examples/taskruns/custom-env.yaml | 10 +++----- examples/taskruns/docker-creds.yaml | 3 +-- examples/taskruns/gcs-resource.yaml | 4 +-- examples/taskruns/git-resource.yaml | 15 +++++------ examples/taskruns/home-is-set.yaml | 10 +++----- examples/taskruns/home-volume.yaml | 11 ++++---- examples/taskruns/old-home-volume.yaml | 13 +++++----- examples/taskruns/pull-private-image.yaml | 3 +-- examples/taskruns/pullrequest.yaml | 9 +++---- examples/taskruns/secret-env.yaml | 7 +++--- examples/taskruns/sidecar-ready.yaml | 2 +- examples/taskruns/steptemplate-env-merge.yaml | 25 +++++++++++-------- .../taskruns/task-multiple-output-image.yaml | 14 ++--------- examples/taskruns/task-output-image.yaml | 15 ++--------- examples/taskruns/unnamed-steps.yaml | 12 ++++----- examples/taskruns/workingdir.yaml | 14 +++++------ examples/taskruns/workspace-volume.yaml | 11 ++++---- 23 files changed, 82 insertions(+), 134 deletions(-) diff --git a/examples/taskruns/build-gcs-targz.yaml b/examples/taskruns/build-gcs-targz.yaml index 1245f3f41a3..6cc97602015 100644 --- a/examples/taskruns/build-gcs-targz.yaml +++ b/examples/taskruns/build-gcs-targz.yaml @@ -10,7 +10,7 @@ spec: type: storage steps: - image: ubuntu - command: ['cat', 'source/file.txt'] # tests build-gcs resource + script: cat source/file.txt inputs: resources: - name: source diff --git a/examples/taskruns/build-gcs-zip.yaml b/examples/taskruns/build-gcs-zip.yaml index abc5b937635..cabce951890 100644 --- a/examples/taskruns/build-gcs-zip.yaml +++ b/examples/taskruns/build-gcs-zip.yaml @@ -10,7 +10,7 @@ spec: type: storage steps: - image: ubuntu - command: ['cat', 'source/file.txt'] # tests build-gcs resource + script: cat source/file.txt inputs: resources: - name: source diff --git a/examples/taskruns/build-push-kaniko.yaml b/examples/taskruns/build-push-kaniko.yaml index 57961f5abc0..b25a263edb1 100644 --- a/examples/taskruns/build-push-kaniko.yaml +++ b/examples/taskruns/build-push-kaniko.yaml @@ -48,8 +48,6 @@ spec: env: - name: "DOCKER_CONFIG" value: "/tekton/home/.docker/" - command: - - /kaniko/executor args: - --dockerfile=$(inputs.params.pathToDockerFile) - --destination=$(outputs.resources.builtImage.url) diff --git a/examples/taskruns/cloud-event.yaml b/examples/taskruns/cloud-event.yaml index c5472c798e3..36afb255d66 100644 --- a/examples/taskruns/cloud-event.yaml +++ b/examples/taskruns/cloud-event.yaml @@ -77,11 +77,8 @@ spec: - name: wait-for-sink image: python:3-alpine imagePullPolicy: IfNotPresent - command: ["/bin/sh"] - args: - - -ce - - | - cat < $(outputs.resources.myimage.path)/index.json { @@ -117,7 +109,6 @@ spec: } ] } - EOF --- apiVersion: tekton.dev/v1alpha1 kind: Task @@ -128,11 +119,8 @@ spec: - name: polling image: python:3-alpine imagePullPolicy: IfNotPresent - command: ["/bin/sh"] - args: - - -ce - - | - cat < /tekton/home/stuff'] + script: echo some stuff > /tekton/home/stuff - name: read image: ubuntu - command: ['cat'] - args: ['/tekton/home/stuff'] + script: cat /tekton/home/stuff - name: override-homevol image: ubuntu - command: ['bash'] # /tekton/home/stuff *doesn't* exist, because the specified volumeMount # conflicts with it, and the user's explicit declaration wins the tie. - args: ['-c', '[[ ! -f /tekton/home/stuff ]]'] + script: | + #!/usr/bin/env bash + [[ ! -f /tekton/home/stuff ]] volumeMounts: - name: empty mountPath: /tekton/home diff --git a/examples/taskruns/old-home-volume.yaml b/examples/taskruns/old-home-volume.yaml index 2c9b7348041..7ead2e1053d 100644 --- a/examples/taskruns/old-home-volume.yaml +++ b/examples/taskruns/old-home-volume.yaml @@ -7,18 +7,17 @@ spec: steps: - name: write image: ubuntu - command: ['bash'] - args: ['-c', 'echo some stuff > /builder/home/stuff'] + script: echo some stuff > /builder/home/stuff - name: read image: ubuntu - command: ['cat'] - args: ['/builder/home/stuff'] + script: cat /builder/home/stuff - name: override-homevol image: ubuntu - command: ['bash'] - # /tekton/home/stuff *doesn't* exist, because the specified volumeMount + # /builder/home/stuff *doesn't* exist, because the specified volumeMount # conflicts with it, and the user's explicit declaration wins the tie. - args: ['-c', '[[ ! -f /builder/home/stuff ]]'] + script: | + #!/usr/bin/env bash + [[ ! -f /builder/home/stuff ]] volumeMounts: - name: empty mountPath: /builder/home diff --git a/examples/taskruns/pull-private-image.yaml b/examples/taskruns/pull-private-image.yaml index 5c4d354967e..bf8e3b8f650 100644 --- a/examples/taskruns/pull-private-image.yaml +++ b/examples/taskruns/pull-private-image.yaml @@ -47,5 +47,4 @@ spec: - name: pull # Private image is just Ubuntu image: quay.io/rhpipeline/skopeo:alpine - command: ["skopeo"] - args: ["copy", "docker://gcr.io/build-crd-testing/secret-sauce", "dir:///tmp/"] + script: skopeo copy docker://gcr.io/build-crd-testing/secret-sauce dir:///tmp/ diff --git a/examples/taskruns/pullrequest.yaml b/examples/taskruns/pullrequest.yaml index ba91587ee12..3714a350ac8 100644 --- a/examples/taskruns/pullrequest.yaml +++ b/examples/taskruns/pullrequest.yaml @@ -20,14 +20,11 @@ spec: steps: - name: dump-workspace image: ubuntu - command: ["sh"] - args: ["-c", "find $(inputs.resources.pr.path)/* -type f | xargs tail -n +1"] + script: find $(inputs.resources.pr.path)/* -type f | xargs tail -n +1 + - name: ensure-approved image: ubuntu - command: ["/bin/bash"] - args: - - -c - - | + script: | if [ -f "$(inputs.resources.pr.path)/labels/approved" ]; then echo "PR is approved!" else diff --git a/examples/taskruns/secret-env.yaml b/examples/taskruns/secret-env.yaml index 0b8c2ba74d5..b7ce1ea3afc 100644 --- a/examples/taskruns/secret-env.yaml +++ b/examples/taskruns/secret-env.yaml @@ -14,10 +14,9 @@ spec: steps: - name: secret image: ubuntu - command: ['bash'] - args: - - '-c' - - '[[ $SECRET_PASSWORD == SECRET_PASSWORD ]]' + script: | + #!/usr/bin/env bash + [[ $SECRET_PASSWORD == SECRET_PASSWORD ]] env: - name: SECRET_PASSWORD valueFrom: diff --git a/examples/taskruns/sidecar-ready.yaml b/examples/taskruns/sidecar-ready.yaml index 8c33ee10728..57b2dd36b94 100644 --- a/examples/taskruns/sidecar-ready.yaml +++ b/examples/taskruns/sidecar-ready.yaml @@ -26,7 +26,7 @@ spec: image: ubuntu # The step will only succeed if the sidecar has written this file, which # it does 5s after it starts, before it reports Ready. - command: ['cat', '/shared/ready'] + script: cat /shared/ready volumeMounts: - name: shared mountPath: /shared diff --git a/examples/taskruns/steptemplate-env-merge.yaml b/examples/taskruns/steptemplate-env-merge.yaml index 77b1069f21e..a991f7c123f 100644 --- a/examples/taskruns/steptemplate-env-merge.yaml +++ b/examples/taskruns/steptemplate-env-merge.yaml @@ -28,35 +28,40 @@ spec: # Test the environment variables are set in the task - name: foo image: ubuntu - command: ["bash"] - args: ["-c", '[[ $(FOO) == "foo" ]]'] + script: | + #!/usr/bin/env bash + [[ $FOO == "foo" ]] env: - name: FOO value: $(inputs.params.FOO) - name: foobar image: ubuntu - command: ["bash"] - args: ["-c", '[[ $(FOOBAR) == "foobar" ]]'] + script: | + #!/usr/bin/env bash + [[ $FOOBAR == "foobar" ]] env: - name: FOOBAR value: $(inputs.params.FOOBAR) - name: bar image: ubuntu - command: ["bash"] - args: ["-c", '[[ $(BAR) == "bar" ]]'] + script: | + #!/usr/bin/env bash + [[ $BAR == "bar" ]] env: - name: BAR value: $(inputs.params.BAR) # Use the env var from the stepTemplate - name: qux-no-override image: ubuntu - command: ["bash"] - args: ["-c", '[[ $(QUX) == "original" ]]'] + script: | + #!/usr/bin/env bash + [[ $QUX == "original" ]] # Override the env var in the stepTemplate - name: qux-override image: ubuntu - command: ["bash"] - args: ["-c", '[[ $(QUX) == "override" ]]'] + script: | + #!/usr/bin/env bash + [[ $QUX == "override" ]] env: - name: QUX value: override diff --git a/examples/taskruns/task-multiple-output-image.yaml b/examples/taskruns/task-multiple-output-image.yaml index e1bdc73b3b2..8a6b7405ef3 100644 --- a/examples/taskruns/task-multiple-output-image.yaml +++ b/examples/taskruns/task-multiple-output-image.yaml @@ -67,11 +67,7 @@ spec: steps: - name: build-and-push-1 image: busybox - command: - - /bin/sh - args: - - -ce - - | + script: | set -ex mkdir -p /tekton/home/image-outputs/builtImage1 cat < /tekton/home/image-outputs/builtImage1/index.json @@ -85,14 +81,9 @@ spec: } ] } - EOF - name: build-and-push-2 image: busybox - command: - - /bin/sh - args: - - -ce - - | + script: | set -e mkdir -p /tekton/home/image-outputs/builtImage2 cat < /tekton/home/image-outputs/builtImage2/index.json @@ -106,7 +97,6 @@ spec: } ] } - EOF --- apiVersion: tekton.dev/v1alpha1 kind: TaskRun diff --git a/examples/taskruns/task-output-image.yaml b/examples/taskruns/task-output-image.yaml index 9325cb103b7..bf3a8e1ba1a 100644 --- a/examples/taskruns/task-output-image.yaml +++ b/examples/taskruns/task-output-image.yaml @@ -56,11 +56,7 @@ spec: steps: - name: build-and-push image: busybox - command: - - /bin/sh - args: - - -ce - - | + script: | set -e cat < $(inputs.resources.sourcerepo.path)/index.json { @@ -73,16 +69,9 @@ spec: } ] } - EOF - name: echo image: busybox - command: - - /bin/sh - args: - - -ce - - | - set -e - cat $(inputs.resources.sourcerepo.path)/index.json + script: cat $(inputs.resources.sourcerepo.path)/index.json --- apiVersion: tekton.dev/v1alpha1 kind: TaskRun diff --git a/examples/taskruns/unnamed-steps.yaml b/examples/taskruns/unnamed-steps.yaml index cd8971df419..a623a7dedbc 100644 --- a/examples/taskruns/unnamed-steps.yaml +++ b/examples/taskruns/unnamed-steps.yaml @@ -5,9 +5,9 @@ metadata: spec: taskSpec: steps: - - image: 'ubuntu' - command: ['true'] - - image: 'ubuntu' - command: ['true'] - - image: 'ubuntu' - command: ['true'] + - image: ubuntu + script: 'true' + - image: ubuntu + script: 'true' + - image: ubuntu + script: 'true' diff --git a/examples/taskruns/workingdir.yaml b/examples/taskruns/workingdir.yaml index e8a7d87fbd1..03d800f90f2 100644 --- a/examples/taskruns/workingdir.yaml +++ b/examples/taskruns/workingdir.yaml @@ -7,15 +7,13 @@ spec: steps: - name: default image: ubuntu - command: ['bash'] - args: - - '-c' - - '[[ $PWD == /workspace ]]' + script: | + #!/usr/bin/env bash + [[ $PWD == /workspace ]] - name: override image: ubuntu - command: ['bash'] workingDir: '/a/path/too/far' - args: - - '-c' - - '[[ $PWD == /a/path/too/far ]]' + script: | + #!/usr/bin/env bash + [[ $PWD == /a/path/too/far ]] diff --git a/examples/taskruns/workspace-volume.yaml b/examples/taskruns/workspace-volume.yaml index ef9e72c36e2..2c59cc1cdd9 100644 --- a/examples/taskruns/workspace-volume.yaml +++ b/examples/taskruns/workspace-volume.yaml @@ -7,18 +7,17 @@ spec: steps: - name: write image: ubuntu - command: ['bash'] - args: ['-c', 'echo some stuff > /workspace/stuff'] + script: echo some stuff > /workspace/stuff - name: read image: ubuntu - command: ['cat'] - args: ['/workspace/stuff'] + script: cat /workspace/stuff - name: override-workspace image: ubuntu - command: ['bash'] # /workspace/stuff *doesn't* exist. - args: ['-c', '[[ ! -f /workspace/stuff ]]'] + script: | + #!/usr/bin/env bash + [[ ! -f /workspace/stuff ]] volumeMounts: - name: empty mountPath: /workspace