-
Notifications
You must be signed in to change notification settings - Fork 1.6k
plugins: validate project and plugin versions #1380
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
plugins: validate project and plugin versions #1380
Conversation
|
@estroz: GitHub didn't allow me to request PR reviews from the following users: Adirio. Note that only kubernetes-sigs members and repo collaborators can review this PR, and authors cannot review their own PRs. In response to this:
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. |
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.
Hi @estroz,
Great 👍 . Just an optional nit and I think would be nice add some tests.
Otherwise, it shows
/lgtm
For me.
bcb985d to
d7aaa06
Compare
d7aaa06 to
ffa2875
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 when pass in the lint.
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
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
ffa2875 to
9485888
Compare
|
/lgtm |
9485888 to
5215a49
Compare
| dns1035LabelFmt string = "[a-z]([-a-z0-9]*[a-z0-9])?" | ||
| ) | ||
|
|
||
| type dnsValidationConfig 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.
@Adirio @camilamacedo86 refactored these for convenience after rebasing onto the feature branch, PTAL.
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 do like the refactor you did, avoiding code duplications through the use of the dnsValidationConfig struct and its check method. A couple of considerations:
- When I read
IsDNS1XXXLabelI instantly imagine afunc (string) boolsignature. As the different errors need to be differentiate, we can not change the function signature to that one, so what about changing the name? Maybe aroundMustBe...orConformsTo.... I guess we could check how the standard library - Returning a
[]stringcontaining the errors doesn't seem very idiomatic in Go. Maybe we should just return anerrorand have the user solve the problem in two steps in case he encounters two errors, as the second one will not be reported until the first one is solved. - Would it make sense to group functions for the same specification? Something in the line of
validation.DNS1XXX.ConformsToLabel(myString). You would have either to export the struct instance or an interface to it:
type DNSValidator interface {
ConformsToLabel(string) error
ConformsToSubdomain(string) error
}
var (
DNS1023 DNSValidator = dns1023Config
DNS1135 DNSValidator = dns1135Config
)They can slo be left for further PRs if you prefer, they are just ideas.
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.
The naming and return values could use some work. Doing this in a follow-up sounds good to me.
pkg/plugin: validation for plugin version strings pkg/internal/validation: project-wide validation logic; move pkg/model/resource/validation.go functions here
5215a49 to
b3d7e23
Compare
|
|
||
| var dns1123LabelConfig = dnsValidationConfig{ | ||
| format: dns1123LabelFmt, | ||
| maxLen: 56, // = 63 - len("-system") |
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.
Non-blocking: I think the validation package should not know about the "-system" prefix, the method should be called with that already prefixed and the maxLen field should be left to 63.
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.
Just to clarifies: The project name will be used as part of the namespace added in the files.
So, it will be <projectname-system>. In this way, when we scaffold the project we cannot allow a projectName with more than 56 characters. However, I agree that how it will be implemented as a hall for improvements like you described.
However, it may not part of the context of this PR as well.
|
/approve |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: DirectXMan12, estroz 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 |
|
An |
|
/ok-to-test |
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
c1f48d0
into
kubernetes-sigs:feature/plugins-part-2-electric-boogaloo
This PR implements plugin version format enforcement. See the plugins design doc and #1290 for more details.
Changes:
pkg/model/resource/validation.gofunctions here/cc @DirectXMan12 @mengqiy @hasbro17 @Adirio