-
Notifications
You must be signed in to change notification settings - Fork 490
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
Update AddressType definition to add domain-prefixed strings as an option #1178
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -480,6 +480,19 @@ type AnnotationKey string | |||||
type AnnotationValue string | ||||||
|
||||||
// AddressType defines how a network address is represented as a text string. | ||||||
// This may take two possible forms: | ||||||
// | ||||||
// * A predefined CamelCase string identifier (currently limited to `IPAddress` or `Hostname`) | ||||||
// * A domain-prefixed string identifier (like `acme.io/CustomAddressType`) | ||||||
// | ||||||
// Values `IPAddress` and `Hostname` have Extended support. | ||||||
// | ||||||
// All other values, including domain-prefixed values have Custom support, | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
// which are used in implementation-specific behaviors. | ||||||
// | ||||||
// +kubebuilder:validation:MinLength=1 | ||||||
// +kubebuilder:validation:MaxLength=253 | ||||||
// +kubebuilder:validation:Pattern=`^([a-zA-Z0-9])+$|^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])\/[a-zA-Z0-9]+$` | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we want a more limited regex here, maybe something like this:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm reluctant to do this, because it means that adding another constant will mean a validation change, which is technically a breaking API change. I'd rather have this validation here, with the constants, and add additional validation in the webhook if required. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've pushed an update that shows what I mean. I think that doing things the way I have here will allow us to add more constants more easily later. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I definitely get the hesitancy to make a validation change, but I think the alternative would result in the following:
I think the argument against stricter validation here could also be used to remove all uses of our enum validation throughout the API because we want to leave room for additional values in the future. I think this is the most relevant part of the API convention guidance:
I think that matches what we're already doing with our other enum fields throughout the API. I'd personally prefer to just give that notice in advance and start with stricter validation here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Discussed in our community meeting today. This seems to have the best possible balance. All the same validation, but leave the validation of the specific constants to the webhook so adding a constant value is easier in the future. I think my only nit here would be to explicitly call out in the godocs here that we may add additional supported values in the future. |
||||||
type AddressType string | ||||||
|
||||||
const ( | ||||||
|
@@ -502,11 +515,4 @@ const ( | |||||
// | ||||||
// Support: Extended | ||||||
HostnameAddressType AddressType = "Hostname" | ||||||
|
||||||
// A NamedAddress provides a way to reference a specific IP address by name. | ||||||
// For example, this may be a name or other unique identifier that refers | ||||||
// to a resource on a cloud provider such as a static IP. | ||||||
// | ||||||
// Support: Implementation-Specific | ||||||
NamedAddressType AddressType = "NamedAddress" | ||||||
) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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've removed this validation because it's moved to the underlying type.