Skip to content

Commit

Permalink
Update some simple examples to use script mode
Browse files Browse the repository at this point in the history
  • Loading branch information
imjasonh committed Nov 26, 2019
1 parent f2daa0b commit 36fc86b
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 41 deletions.
33 changes: 17 additions & 16 deletions docs/tasks.md
Original file line number Diff line number Diff line change
Expand Up @@ -416,11 +416,8 @@ use it to build a docker image:
steps:
- image: docker
name: client
workingDir: /workspace
command:
- /bin/sh
- -c
- |
script: |
#!/usr/bin/env bash
cat > Dockerfile << EOF
FROM ubuntu
RUN apt-get update
Expand Down Expand Up @@ -463,7 +460,7 @@ has been created to track this bug.
[`outputs`](#outputs).


Input parameters can be referenced in the `Task` spec using the variable substitution syntax below,
Input parameters can be referenced in the `Task` spec using the variable substitution syntax below,
where `<name>` is the name of the parameter:

```shell
Expand All @@ -481,19 +478,19 @@ So, with the following parameter:
inputs:
params:
- name: array-param
value:
value:
- "some"
- "array"
- "elements"
```
then `command: ["first", "$(inputs.params.array-param)", "last"]` will become
then `command: ["first", "$(inputs.params.array-param)", "last"]` will become
`command: ["first", "some", "array", "elements", "last"]`


Note that array parameters __*must*__ be referenced in a completely isolated string within a larger string array.
Any other attempt to reference an array is invalid and will throw an error.
Note that array parameters __*must*__ be referenced in a completely isolated string within a larger string array.
Any other attempt to reference an array is invalid and will throw an error.

For instance, if `build-args` is a declared parameter of type `array`, then this is an invalid step because
For instance, if `build-args` is a declared parameter of type `array`, then this is an invalid step because
the string isn't isolated:
```
- name: build-step
Expand Down Expand Up @@ -608,14 +605,17 @@ Mounting multiple volumes:
spec:
steps:
- image: ubuntu
entrypoint: ["bash"]
args: ["-c", "curl https://foo.com > /var/my-volume"]
script: |
#!/usr/bin/env bash
curl https://foo.com > /var/my-volume
volumeMounts:
- name: my-volume
mountPath: /var/my-volume

- image: ubuntu
args: ["cat", "/etc/my-volume"]
script: |
#!/usr/bin/env bash
cat /etc/my-volume
volumeMounts:
- name: my-volume
mountPath: /etc/my-volume
Expand All @@ -639,8 +639,9 @@ spec:
description: Name of volume
steps:
- image: ubuntu
entrypoint: ["bash"]
args: ["-c", "cat /var/configmap/test"]
script: |
#!/usr/bin/env bash
cat /var/configmap/test
volumeMounts:
- name: "$(inputs.params.volumeName)"
mountPath: /var/configmap
Expand Down
10 changes: 6 additions & 4 deletions examples/taskruns/custom-volume.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,17 @@ spec:
steps:
- name: write
image: ubuntu
command: ["/bin/bash"]
args: ["-c", "echo some stuff > /im/a/custom/mount/path/file"]
script: |
#!/usr/bin/env bash
echo some stuff > /im/a/custom/mount/path/file
volumeMounts:
- name: custom
mountPath: /im/a/custom/mount/path
- name: read
image: ubuntu
command: ["/bin/bash"]
args: ["-c", "cat /short/and/stout/file"]
script: |
#!/usr/bin/env bash
cat /short/and/stout/file
volumeMounts:
- name: custom
mountPath: /short/and/stout
Expand Down
6 changes: 2 additions & 4 deletions examples/taskruns/dind-sidecar.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@ spec:
- image: docker
name: client
workingDir: /workspace
command:
- /bin/sh
- -c
- |
script: |
#!/usr/bin/env sh
cat > Dockerfile << EOF
FROM ubuntu
RUN apt-get update
Expand Down
5 changes: 3 additions & 2 deletions examples/taskruns/git-ssh-creds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,6 @@ spec:
steps:
- name: config
image: ubuntu
command: ["/bin/bash"]
args: ["-c", "cat /workspace/gitssh/README.md"]
script: |
#!/usr/bin/env bash
cat /workspace/gitssh/README.md
6 changes: 2 additions & 4 deletions examples/taskruns/secret-volume-params.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@ spec:
type: string
steps:
- image: ubuntu
command:
- '/bin/bash'
- '-c'
- |
script: |
#!/usr/bin/env bash
SECRET_PASSWORD=$(cat /var/secret/ninja)
[[ $SECRET_PASSWORD == SECRET_PASSWORD ]]
volumeMounts:
Expand Down
6 changes: 2 additions & 4 deletions examples/taskruns/secret-volume.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,8 @@ spec:
taskSpec:
steps:
- image: ubuntu
command:
- '/bin/bash'
- '-c'
- |
script: |
#!/usr/bin/env bash
SECRET_PASSWORD=$(cat /var/secret/ninja)
[[ $SECRET_PASSWORD == SECRET_PASSWORD ]]
volumeMounts:
Expand Down
7 changes: 4 additions & 3 deletions examples/taskruns/task-volume-args.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ data:
apiVersion: tekton.dev/v1alpha1
kind: TaskRun
metadata:
name: configmap-volume
generateName: task-volume-args-
spec:
taskSpec:
inputs:
Expand All @@ -19,8 +19,9 @@ spec:
steps:
- name: read
image: ubuntu
command: ["/bin/bash"]
args: ["-c", "cat /configmap/test.data"]
script: |
#!/usr/bin/env bash
cat /configmap/test.data
volumeMounts:
- name: custom
mountPath: /configmap
Expand Down
10 changes: 6 additions & 4 deletions examples/taskruns/template-volume.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,17 @@ spec:
steps:
- name: write
image: ubuntu
command: ["/bin/bash"]
args: ["-c", "echo some stuff > /im/a/custom/mount/path/file"]
script: |
#!/usr/bin/env bash
echo some stuff > /im/a/custom/mount/path/file
volumeMounts:
- name: custom
mountPath: /im/a/custom/mount/path
- name: read
image: ubuntu
command: ["/bin/bash"]
args: ["-c", "cat /short/and/stout/file"]
script: |
#!/usr/bin/env bash
cat /short/and/stout/file
volumeMounts:
- name: custom
mountPath: /short/and/stout
Expand Down

0 comments on commit 36fc86b

Please sign in to comment.