-
Notifications
You must be signed in to change notification settings - Fork 107
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
Params EP Implementation #781
Params EP Implementation #781
Conversation
4c01830
to
1928515
Compare
15bdb71
to
7852d9f
Compare
410baa6
to
eb8209c
Compare
d509e90
to
4e696a3
Compare
4e696a3
to
2294c13
Compare
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 work. I have so many use cases in mind to leverage that. :-)
Based on our usual agreement, as it contains API changes, requires a second review. @imjasonh having some minutes?
/approve
/assign imjasonh
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: SaschaSchwarze0 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 |
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.
Mostly lgtm, some small readability comments but otherwise nothing structural.
Thanks for this PR, and sorry it took so long for me to review it.
} | ||
|
||
// override params that matches by name in both originalParams and overrideParams | ||
for i, o := range originalParams { |
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 might be a bit more readable and performant to first convert both lists into map[string]Param, then you can do lookups without having to double-loop.
I don't think in practice the performance will be noticeable, but I get nervous any time I see nested for
s.
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, good idea, done.
@@ -37,6 +38,10 @@ const ( | |||
inputParamContextDir = "CONTEXT_DIR" | |||
) | |||
|
|||
var ( | |||
systemReservedParametersRegexp = regexp.MustCompile("BUILDER_IMAGE|DOCKERFILE|CONTEXT_DIR|(shp-.*)") |
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.
Could this instead be expressed as a helper function that checks if the string is in a set of disallowed strings, and doesn't have the shp-
prefix?
I find that regular expressions can be hard to read and understand, which can lead to bugs. If it can be implemented in reasonably brief code that's usually better in my experience:
var reserved := map[string]bool{
"BUILDER_IMAGE": true,
"DOCKERFILE": true,
"CONTEXT_DIR": true,
}
func isReserved(n string) bool {
return reserved[n] || strings.HasPrefix("shp-")
}
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, nice, done.
5b46715
to
f014205
Compare
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.
@imjasonh added all your request for changes, thanks
90956bf
to
a1e0909
Compare
pkg/apis/build/v1alpha1/parameter.go
Outdated
type Parameter struct { | ||
// Param is a key/value that populates a strategy parameter | ||
// used in the execution of the strategy steps | ||
type Param struct { |
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.
How do you feel about ParamValue
, a field named paramValues:
, etc.? It's a bit confusing to have both Parameter
and Param
types (Tekton has this issue as well)
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.
not my favorite field name tbh, but I see the benefit. The concern I have now, is that these naming conventions were already accepted via the related EP before, by different people.
My options on this:
- Block this till consensus from more folks, as the change
params
->paramValues
is high. - Merge this, and then look for consensus. If we need to change this, then we PR the change.
What do you think?
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.
@imjasonh I did the changes as requested. FYI I sync on this offline with @SaschaSchwarze0 and @HeavyWombat , we all agree its a good alternative. Please re-review this PR again.
a1e0909
to
3a9cdf1
Compare
Extend Build and BuildRun to support spec.params Extend the Strategies to support spec.parameters Regenerate CRD´s files
Support test cases for using params. Apply this to both namespaced and cluster-scope strategies.
Ensure that on TaskRun creation we can add the strategy parameters as part of the Task parameters, and that we populate their values via the Build/BuildRun params definition.
Validate that a param is: - not colliding with system parameters - exists in the strategy parameters - overrides via a BuildRun can happen, as long as the param exists in the Build Also extend Build custom errors, to support two new ones: - RestrictedParametersInUse - UndefinedParameter
- Extend Build docs - Extend BuildRun docs - Extend Strategy docs - Update parameterize EP and set to `implemented`.
Make a clear distinction on calling the Build/BuildRun params as `spec.paramValues` instead of `spec.params`
3a9cdf1
to
1970780
Compare
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
Thanks!
Changes
Implements the parameterize-strategies EP
Note: I modified the API, as
spec.params
in all CRD´s might be confusing I decided to use:spec.params
for Build and BuildRunsspec.parameters
for Strategies.I would open another PR after this one gets merged, to introduce a tutorial on how to build a strategy with parameters.
Submitter Checklist
Release Notes