-
Notifications
You must be signed in to change notification settings - Fork 261
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
⚠️ ImageFilter - add exclusive validation -> pointers #1939
⚠️ ImageFilter - add exclusive validation -> pointers #1939
Conversation
✅ Deploy Preview for kubernetes-sigs-cluster-api-openstack ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
b94518a
to
f7ccaaa
Compare
/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.
Nice! Approved, but I'd appreciate it if you could add the additional requested test and fix the nit.
// The ID of the desired image. If this is provided, the other filters will be ignored. | ||
ID string `json:"id,omitempty"` | ||
// The ID of the desired image. If ID is provided, the other filters cannot be provided. | ||
// +kubebuilder:validation:Format:=uuid |
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.
Please can you also add a test for uuid format validation?
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 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! Please can you add one more test that an invalid uuid is rejected?
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.
@@ -43,7 +43,7 @@ type OpenStackMachineSpec struct { | |||
|
|||
// The image to use for your server instance. | |||
// If the rootVolume is specified, this will be used when creating the root volume. | |||
Image ImageFilter `json:"image,omitempty"` | |||
Image ImageFilter `json:"image"` |
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.
Please can you add an explicit // +optional
?
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 wasn't exactly sure if the image is optional. Is it? Should I make it Image *ImageFilter
then?
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 think we can't make ImageFilter
optional, code requires that the exactly one image will be found. An empty ImageFilter
might be possible and resolvable if you have just one image in that tenant.
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.
D'oh. Of course this should not be optional. Yep, lets make it explicitly required.
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: dulek, mdbooth 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 |
@mdbooth: I fixed a comment, but I'm still unsure about |
/test pull-cluster-api-provider-openstack-e2e-full-test I think all comments were addressed (nice work!) but I'll let Matt hold cancel. |
So we still wanted to add validation that when ID is not set, the filter has at least one other option set. Now I started working on Bastion to fix this, because this means we're unable to create an empty machine, but maybe it's an overkill. Technically an empty filter is still valid if you have just one image. |
This commit changes `ID` and `Name` of `ImageFilter` to pointers which should only affect go marshalling. Other than that it adds CEL validation of the ImageFilter, so that Name or Tags can only be set when ID is unset. Conversions are updated accordingly to make sure we only set Name when ID is unset. Moreover validation is added that ID has to be UUID. It's not enforced in conversions, as non-UUID IDs would produce clusters or machines that would not work properly.
This adds tests related to kubebuilder validations of ImageFilter.
I added the explicit |
/retest |
/test pull-cluster-api-provider-openstack-e2e-full-test |
/hold cancel |
What this PR does / why we need it:
This commit changes
ID
andName
ofImageFilter
to pointers which should only affect go marshalling.Other than that it adds CEL validation of the ImageFilter, so that Name or Tags can only be set when ID is unset. Conversions are updated accordingly to make sure we only set Name when ID is unset.
Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):Fixes #
Special notes for your reviewer:
TODOs:
/hold