Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update some simple examples to use script mode #1469

Merged
merged 1 commit into from
Nov 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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: |
imjasonh marked this conversation as resolved.
Show resolved Hide resolved
#!/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: |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: this might be even simpler with https://hub.docker.com/r/curlimages/curl

#!/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