-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement Task/TaskRun Input Parameters.
This adds support for Task/TaskRun Input Parameters using the 'ApplyReplacements' function from knative/build. Reusing this function ensures consistency in variable replacement between the projects. This change assumes that the supplied TaskRun.Spec.Inputs.Params have been valided against the Task.Inputs.Params elsewhere. We may want to revisit this and perform additional validation. This change does not introduce support for Resources or PipelineParams yet.
- Loading branch information
Showing
7 changed files
with
462 additions
and
53 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
## Task Parameters | ||
|
||
Tasks can declare input parameters that must be supplied to the task during a TaskRun. | ||
Some example use-cases of this include: | ||
|
||
* A task that needs to know what compilation flags to use when building an application. | ||
* A task that needs to know what to name a built artifact. | ||
* A task that supports several different strategies, and leaves the choice up to the other. | ||
|
||
### Usage | ||
|
||
The following example shows how Tasks can be parameterized, and these parameters can be passed to the `Task` from a `TaskRun`. | ||
|
||
Input parameters in the form of `${inputs.foo}` are replaced inside of the buildSpec. | ||
|
||
The following `Task` declares an input parameter called 'flags', and uses it in the `buildSpec.steps.args` list. | ||
|
||
```yaml | ||
apiVersion: pipeline.knative.dev/v1alpha1 | ||
kind: Task | ||
metadata: | ||
name: task-with-parameters | ||
spec: | ||
inputs: | ||
params: | ||
- name: flags | ||
value: string | ||
buildSpec: | ||
steps: | ||
- name: build | ||
image: my-builder | ||
args: ['build', '--flags=${inputs.flags}'] | ||
``` | ||
The following `TaskRun` supplies a value for `flags`: | ||
|
||
```yaml | ||
apiVersion: pipeline.knative.dev/v1alpha1 | ||
kind: TaskRun | ||
metadata: | ||
name: run-with-parameters | ||
spec: | ||
taskRef: | ||
name: task-with-parameters | ||
inputs: | ||
params: | ||
- name: 'flags' | ||
value: 'foo=bar,baz=bat' | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.