-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
baremetal: platform host validations #3232
baremetal: platform host validations #3232
Conversation
/label platform/baremetal |
On 45da73f, the commit message could have a little more detail. It's not just duplicates, and should mention that it's for baremetal. @abhinavdahiya PTAL - alternative approach to #3208 |
/assign @abhinavdahiya |
Build FAILURE, see build http://10.8.144.11:8080/job/dev-tools/1563/ |
Personally I don't see how this helps, it's more magic with fields parent tags etc, uses reflect for later reporting. The only benefit was required was reduced, and that kind of already easy to DRY out.. and in cases where required needs more special handling like required when this other thing is set, we will end up creating these new tags or write that logic anyway. So I like the previous method as it's more easy to ready, extend. |
A validation rule is identified by a tag. So it's just a matter to annotate which fields of which struct are required to be validate against which rules. And the framework already offers many pre-baked rules, and by default allows to apply the validation to nested struct (see for example the |
I like the annotation based approach for validations, rather than having the same checks over and over again in each platform's validations. The general case is more common than a special case ("if this field, then that one" or other constraints) and would probably simplify most platforms. |
more than happy to approve the vendoring after this PR is LGTM from baremetal-approvers. If the baremetal validations are more successful with this approach we can look at expanding them. |
fieldValues[fieldValue] = struct{}{} | ||
} | ||
} else { | ||
panic(fmt.Sprintf("Cannot apply validation rule 'uniqueField' on field %s", fl.FieldName())) |
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.
panics are less desirable in the code for installer
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.
Wasn't sure about the standard adopted, I noticed that it was used somewhere (https://github.com/openshift/installer/search?q=panic+-path%3A%2Fvendor&unscoped_q=panic+-path%3A%2Fvendor) and thought it could have been useful in case of configuration mistake. But if it's not I'll remove it.
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.
A panic seems fair here, this would only happen if a dev adds the annotation that a field is uniqueValue and it's not Comparable.
Build FAILURE, see build http://10.8.144.11:8080/job/dev-tools/1581/ |
Build FAILURE, see build http://10.8.144.11:8080/job/dev-tools/1584/ |
/test pj-rehearse |
/test golint |
I'm happy with this version. @andfasano Could you clean up the commit history? Should be 1 vendor commit, 1 code commit |
5d1a65d
to
3b5d253
Compare
Cleanup done, please let me know if it's ok |
/lgtm @abhinavdahiya PTAL, thanks! |
b47a051 LGTM /approve |
3b5d253
to
ec00344
Compare
vendor/modules.txt
Outdated
@@ -919,10 +926,15 @@ github.com/keybase/go-crypto/rsa | |||
github.com/konsorten/go-windows-terminal-sequences | |||
# github.com/kr/fs v0.1.0 | |||
github.com/kr/fs | |||
<<<<<<< HEAD |
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.
Looks like there's still an unresolved conflict
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 run go mod tidy && go mod vendor instead of trying to solve the merge conflict.. maybe?
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.
Sorry my fault I'll do it asap
This module simplify and make more scalable the validation steps, It's annotations based, offers a good set of pre-existing validation rules and allows to add easily new custom validation rules
baremetal.Host is validated using go-playground/validator module and a custom defined rule for duplicates
ec00344
to
508e7e4
Compare
Build SUCCESS, see build http://10.8.144.11:8080/job/dev-tools/1658/ |
/hold cancel |
/retest |
/lgtm |
/retest Please review the full test history for this PR and help us cut down flakes. |
11 similar comments
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
@andfasano: The following tests failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. 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. I understand the commands that are listed here. |
This change proposes the same host validations already described in another PR (#3208 thanks to @stbenjam) but using the go-playground/validator module to make the validation process easier, reusable and more scalable, and helping in reducing the amount of code requested.
This change only affects the host validations by reusing an existing validation rule and adding a custom one for detecting duplicated values, but it could also be easily adopted for other kind of validations.