-
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
Add validation for duplicated param names in TaskSpec #4806
Add validation for duplicated param names in TaskSpec #4806
Conversation
Hi @chitrangpatel. Thanks for your PR. I'm waiting for a tektoncd member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/ok-to-test |
The following is the coverage report on the affected files.
|
d22579e
to
09a0bc2
Compare
The following is the coverage report on the affected files.
|
/retest |
The following is the coverage report on the affected files.
|
/test pull-tekton-pipeline-alpha-integration-tests |
The following is the coverage report on the affected files.
|
/test pull-tekton-pipeline-alpha-integration-tests |
errs = errs.Also(validateParameterNames(ts.Params).ViaField("params")) | ||
errs = errs.Also(ValidateParameterTypes(ts.Params).ViaField("params")) |
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: we could have a ValidateParamSpecs
function that does both of those at the same time. Probably an opmitization at that point of time though.
/retest |
f09d585
to
09e8c44
Compare
09e8c44
to
d4f8711
Compare
/retest |
The following is the coverage report on the affected files.
|
/assign @vdemeester |
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 Chitrang for fixing this issue!
@@ -244,6 +244,17 @@ func validateStep(ctx context.Context, s Step, names sets.String) (errs *apis.Fi | |||
return errs | |||
} | |||
|
|||
// ValidateParameterSpecs validates that there are no duplicate names in the TaskSpec and all the types within a slice of ParamSpecs. | |||
func validateParameterSpecs(params []ParamSpec) (errs *apis.FieldError) { |
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.
I think it might make more sense to add this validation to the function ValidateParameterVariables, and likewise in ValidatePipelineParameterVariables
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.
Agreed! I made the necessary changes.
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.
It doesn't look like the changes were applied to ValidatePipelineParameterVariables?
Also, no need to make any changes to v1alpha1
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.
validatePipelineParameterVariables
was already checking for duplicated param names and param types so no changed needed to be made there. It was only missing at the task validation stage.
Yes, now that I moved the function call to validateParamTypes back to where it was, ctx
was no longer required by ValidateParameterVariables
and so the change to v1alpha1
was also undone.
05aa6fe
to
b30f933
Compare
The following is the coverage report on the affected files.
|
func ValidateParameterVariables(steps []Step, params []ParamSpec) *apis.FieldError { | ||
func ValidateParameterVariables(ctx context.Context, steps []Step, params []ParamSpec) *apis.FieldError { | ||
// Validate Parameter Types | ||
errs := ValidateParameterTypes(ctx, params).ViaField("params") |
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.
I think the call to this function is OK to stay where it was
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.
Right. That will simplify things since I don't need to pass in the context
which is why I also had to make changes to v1alpha1
.
Prior to this, when duplicated names for parameters were assigned in `taskSpec`, the param value would be overwritten by the last value. To avoid this, a validation check was added to ensure that no param name is duplicated in TaskSpec.
b30f933
to
1d67120
Compare
The following is the coverage report on the affected files.
|
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.
/lgtm
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: lbernick, vdemeester 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 |
Prior to this, when duplicated names for parameters were assigned in
taskSpec
, the param value would be overwritten by the last value.Changes
To avoid this, a validation check was added to ensure that no param name
is duplicated in TaskSpec. This PR address issue #4798.
Submitter Checklist
As the author of this PR, please check off the items in this checklist:
functionality, content, code)
(if there are no user facing changes, use release note "NONE")
Release Notes