-
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.
While working on allowing PipelineRuns to provide extra parameters (#2513), we found that providing extra parameters was unintentionally allowed. That's because, currently, there's no validation that all parameters expected by the Pipeline is provided by the PipelineRun. In this PR, we add validation for PipelineRun parameters by generating a list of provided parameters then iterating through the expected parameters to ensure they are in the list of provided parameters. In the validation, we still allow PipelineRuns to provide extra parameters. If we disallow PipelineRuns from provides extra parameters, the Pipelines would fail. As a result, systems that autogenerate PipelineRuns need to lookat each pipeline to see what parameters they need so it can provide only the required parameters. That means users would have to resort to more complex designs to solve this issue, as further described in (#2513). By allowing PipelineRuns to provide extra parameters, we make the process of autogenerating of PipelineRuns simpler. Fixes #2708.
- Loading branch information
Showing
6 changed files
with
201 additions
and
0 deletions.
There are no files selected for viewing
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
58 changes: 58 additions & 0 deletions
58
examples/v1beta1/pipelineruns/pipelinerun-with-extra-params.yaml
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,58 @@ | ||
apiVersion: tekton.dev/v1beta1 | ||
kind: Pipeline | ||
metadata: | ||
name: pipeline-with-extra-params | ||
spec: | ||
params: | ||
- name: pl-param-x | ||
type: string | ||
- name: pl-param-y | ||
type: string | ||
tasks: | ||
- name: add-params | ||
taskRef: | ||
name: add-params | ||
params: | ||
- name: a | ||
value: "$(params.pl-param-x)" | ||
- name: b | ||
value: "$(params.pl-param-y)" | ||
--- | ||
apiVersion: tekton.dev/v1alpha1 | ||
kind: Task | ||
metadata: | ||
name: add-params | ||
annotations: | ||
description: | | ||
A simple task that sums the two provided integers | ||
spec: | ||
inputs: | ||
params: | ||
- name: a | ||
type: string | ||
description: The first integer | ||
- name: b | ||
type: string | ||
description: The second integer | ||
steps: | ||
- name: sum | ||
image: bash:latest | ||
script: | | ||
#!/usr/bin/env bash | ||
echo -n $(( "$(inputs.params.a)" + "$(inputs.params.b)" )) | ||
--- | ||
apiVersion: tekton.dev/v1alpha1 | ||
kind: PipelineRun | ||
metadata: | ||
generateName: pipelinerun-with-extra-params | ||
spec: | ||
params: | ||
- name: pl-param-x | ||
value: "100" | ||
- name: pl-param-y | ||
value: "200" | ||
- name: pl-param-z # the extra parameter | ||
value: "300" | ||
pipelineRef: | ||
name: pipeline-with-extra-params | ||
|
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
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