Skip to content

Commit

Permalink
Add example and docs for array param with defaults 📜
Browse files Browse the repository at this point in the history
While working on (finally) updating the array result and object
param/result TEPs (tektoncd/community#479
tektoncd/community#477) I realized I hadn't
included an example of how to specify defaults for the new format, so I
looked for an example of how we currently do this for arrays, but we had
none! Hopefully now we do :D
  • Loading branch information
bobcatfish committed Jan 26, 2022
1 parent 4186dc9 commit 8de5615
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docs/pipelines.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ For more information, see:

## Specifying `Parameters`

(See also [Specifying Parameters in Tasks](tasks.md#specifying-parameters))

You can specify global parameters, such as compilation flags or artifact names, that you want to supply
to the `Pipeline` at execution time. `Parameters` are passed to the `Pipeline` from its corresponding
`PipelineRun` and can replace template values specified within each `Task` in the `Pipeline`.
Expand Down
17 changes: 17 additions & 0 deletions docs/tasks.md
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,23 @@ spec:
value: "http://google.com"
```
Parameter declarations include default values which will be used if the parameter is not specified, for example to
specify defaults for both string params and array params ([full example](../examples/v1beta1/taskruns/array-default.yaml)) :
```yaml
params:
- name: flags
type: array
- name: flags-default
type: array
default:
- "foo-default"
- "bar-default"
- name: singleVal
type: string
default: "baz"
```
### Specifying `Resources`

> :warning: **`PipelineResources` are [deprecated](deprecations.md#deprecation-table).**
Expand Down
32 changes: 32 additions & 0 deletions examples/v1beta1/taskruns/array-default.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
apiVersion: tekton.dev/v1beta1
kind: TaskRun
metadata:
generateName: array-with-default-
spec:
params:
- name: flags
value:
- "foo"
- "bar"
taskSpec:
params:
- name: flags
type: array
- name: flags-default
type: array
default:
- "foo-default"
- "bar-default"
- name: singleVal
type: string
default: "baz"
steps:
- name: build
image: bash:3.2
args: [
"echo",
"$(params.flags[*])",
"$(params.flags-default[*])",
"$(params.singleVal)",
]

0 comments on commit 8de5615

Please sign in to comment.