-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Parameter variable substitution support for conditionals #1143
Conversation
The following is the coverage report on pkg/.
|
The following is the coverage report on pkg/.
|
"github.com/tektoncd/pipeline/pkg/templating" | ||
) | ||
|
||
func TestApplyContainerReplacements(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for improving the test coverage here!
Since you're at it 👼 it would be nice to test the case of replacement when the variable is not defined.
The following is the coverage report on pkg/.
|
pkg/reconciler/v1alpha1/pipelinerun/resources/conditionresolution.go
Outdated
Show resolved
Hide resolved
The following is the coverage report on pkg/.
|
/lgtm |
I've not reviewed the code yet, but I noticed that the params are limited to string - I wonder if we should support the newly added array params too? That could be a separate PR of course. |
Array params should be supported for the |
This makes it easier to reuse this functionality across taskruns and conditions. Signed-off-by: Dibyo Mukherjee <[email protected]>
A Condition's `spec.Check` can refer to its declared parameters using the ${params.param-name} syntax just like in a Task. Values can be provided via the pipelinerun's parameters or via default values in the condition or in the PipelineTaskCondition Signed-off-by: Dibyo Mukherjee <[email protected]>
The following is the coverage report on pkg/.
|
/lgtm |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, nice work!!
I have a couple of minor comments, but nothing important so I'm going to approve this anyways.
parameter name, `barIsBa$` or `0banana` are not. | ||
|
||
Each declared parameter has a type field, assumed to be string if not provided by the user. | ||
The other possible type is array — useful,checking a pushed branch name doesn't match any of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT: space after the comma
parameter name, `barIsBa$` or `0banana` are not. | ||
|
||
Each declared parameter has a type field, assumed to be string if not provided by the user. | ||
The other possible type is array — useful,checking a pushed branch name doesn't match any of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT: space after the comma
} | ||
|
||
return p | ||
} | ||
|
||
func replaceParamValues(params []v1alpha1.Param, stringReplacements map[string]string, arrayReplacements map[string][]string) []v1alpha1.Param { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice :)
@@ -69,6 +70,49 @@ func TestApplyParameters(t *testing.T) { | |||
tb.PipelineTask("first-task-1", "first-task", | |||
tb.PipelineTaskParam("first-task-first-param", "${input.workspace.default-value}"), | |||
))), | |||
}, { | |||
name: "single parameter in task condition", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT: I guess the test name refers to the amount of parameters passed in the run? One is left to default and one not. Perhaps the name could be changed?
), | ||
))), | ||
}, { | ||
name: "pipeline parameter nested inside condition parameter", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT: again, the name of the test is a bit confusing for me, in this case there is only one parameter and it's left to default.
"github.com/tektoncd/pipeline/pkg/templating" | ||
) | ||
|
||
func TestApplyContainerReplacements(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for improving the test coverage here!
Since you're at it 👼 it would be nice to test the case of replacement when the variable is not defined.
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: afrittoli, dibyom The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Changes
Add parameter variable substitution support for conditionals
A Condition's
spec.Check
can refer to its declared parameters usingthe ${params.param-name} syntax just like in a Task. Values can be
provided via the pipelinerun's parameters or via default values in the
condition or in the PipelineTaskCondition
Submitter Checklist
These are the criteria that every PR should meet, please check them off as you
review them:
Part of #1019, #1137
Release Notes