-
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
[TEP-0076] Add indexing into array for taskrun params reference #5132
[TEP-0076] Add indexing into array for taskrun params reference #5132
Conversation
Skipping CI for Draft Pull Request. |
/kind feature |
2f5fda9
to
082d60c
Compare
@@ -58,6 +59,12 @@ func ApplyParameters(spec *v1beta1.TaskSpec, tr *v1beta1.TaskRun, defaults ...v1 | |||
switch p.Default.Type { | |||
case v1beta1.ParamTypeArray: | |||
for _, pattern := range patterns { | |||
// array indexing for param is alpha feature |
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.
out of scope for this PR, but these two for loops have a lot of duplicate code that could be consolidated.
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.
yes, we can also refactor the code in pipelinerun as well
@@ -353,3 +369,200 @@ func missingKeysofObjectResults(tr *v1beta1.TaskRun, specResults []v1beta1.TaskR | |||
} | |||
return findMissingKeys(neededKeys, providedKeys) | |||
} | |||
|
|||
func validateParamArrayIndex(ctx context.Context, params []v1beta1.Param, spec *v1beta1.TaskSpec) error { |
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.
this block of code looks extremely similar to what was introduced in the pipelinerun reconciler. Can any of it be moved to a common location?
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.
yes! I was thinking if we want to merge the results code from taskrun and pipelinerun into one pkg then they can share functions like this.
Right now I'm not so sure where can I put it. Maybe pkg/reconciler/resources.go ?
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.
Oh but this function is different, the one in pipelinerun will traverse all pipelinespec fields and this is to traverse TaskSpec, another function extractParamIndex
is the same and can be merged
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'm not sure if you're referring to extractParamIndex
here or extractParamIndexes
in the PR reconciler but either way yes they could be pulled out. I'd create a new package pkg/params
and put it there in a separate PR
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.
sure, so maybe this is part of our refactoring work later?
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'm ok with this for now, but typically I'd caution against saving refactoring work for after a feature is implemented. I don't think the changes I'm suggesting will take much time.
The following is the coverage report on the affected files.
|
The following is the coverage report on the affected files.
|
This commit provides the indexing into array for params and gated by alpha feature flag. Before this commit we can only refer to the whole array for taskrun params, with this feature we can refer to array's element such as $(params.param-name[0]).
2309bca
to
754a52c
Compare
The following is the coverage report on the affected files.
|
/assign @ywluogg |
@@ -353,3 +369,200 @@ func missingKeysofObjectResults(tr *v1beta1.TaskRun, specResults []v1beta1.TaskR | |||
} | |||
return findMissingKeys(neededKeys, providedKeys) | |||
} | |||
|
|||
func validateParamArrayIndex(ctx context.Context, params []v1beta1.Param, spec *v1beta1.TaskSpec) error { |
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'm ok with this for now, but typically I'd caution against saving refactoring work for after a feature is implemented. I don't think the changes I'm suggesting will take much time.
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: lbernick 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 |
/lgtm |
/retest |
2 similar comments
/retest |
/retest |
/retest-required |
3 similar comments
/retest-required |
/retest-required |
/retest-required |
Changes
This commit provides the indexing into array for params and gated by
alpha feature flag. Before this commit we can only refer to the whole
array for taskrun params, with this feature we can refer to array's element such as
$(params.param-name[0]).
/kind feature
Submitter Checklist
As the author of this PR, please check off the items in this checklist:
functionality, content, code)
/kind <type>
. Valid types are bug, cleanup, design, documentation, feature, flake, misc, question, tepRelease Notes