-
Notifications
You must be signed in to change notification settings - Fork 290
🌱 Ensure BMH name is a valid DNS label #2636
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
base: main
Are you sure you want to change the base?
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Hi @nerok. Thanks for your PR. I'm waiting for a metal3-io 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. DetailsInstructions 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-sigs/prow repository. |
|
|
||
| func validateBMHName(bmhname string) error { | ||
| invalidname, _ := regexp.MatchString(`[^A-Za-z0-9\.\-\_]`, bmhname) | ||
| invalidname, _ := regexp.MatchString(`[^A-Za-z0-9\-]`, bmhname) |
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.
There is more to validating a DNS name than this; e.g. it cannot start or end with a -, should be no more than 63 characters.
I suggest calling this function to validate 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.
Changed to that function now, some tests needed changes, and otherwise I added (maybe too many) tests to validate that we check what we think we check.
|
/ok-to-test |
af3791d to
1949fc3
Compare
tuminoid
left a comment
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.
CR names are actually already validated against Ideally we would only call this from |
|
Should the length check be moved to ValidateCreate then, so it isn't ran on changes? Or should validateChanges pick that error out and rather log it? Those are the alternatives I could come up with |
|
I think moving it to validateCreate makes sense |
1949fc3 to
f48f68c
Compare
f48f68c to
3846355
Compare
Signed-off-by: Didrik Frimann Barroso Koren <[email protected]>
3846355 to
b1f82c9
Compare
|
It got a lot more complicated to ignore or reimplement the validations, so I think this solution was simple enough. |
tuminoid
left a comment
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
/cc @zaneb
|
(LGTM) |
What this PR does / why we need it:
We don't want anyone to create a BMH with a name which isn't a compliant DNS hostname, that will cause issues.
Which issue(s) this PR fixes:
Fixes parts of #855