Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 83
⚠️ update name validation patterns to match Kubernetes as close as possible#1175
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
Merged
joelanford
merged 2 commits into
operator-framework:main
from
everettraven:chore/kubernetes-naming-validationsSep 4, 2024
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -67,7 +67,7 @@ type ClusterExtensionSpec struct { | ||
| // applied to other Namespaces. This Namespace is expected to exist. | ||
| // | ||
| // installNamespace is required, immutable, and follows the DNS label standard | ||
| // as defined in RFC 1123. This means that valid values: | ||
| // as defined in [RFC 1123]. This means that valid values: | ||
| // - Contain no more than 63 characters | ||
everettraven marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| // - Contain only lowercase alphanumeric characters or '-' | ||
| // - Start with an alphanumeric character | ||
| @@ -85,6 +85,8 @@ type ClusterExtensionSpec struct { | ||
| // - thisisareallylongnamespacenamethatisgreaterthanthemaximumlength | ||
| // - some.namespace | ||
| // | ||
| // [RFC 1123]: https://tools.ietf.org/html/rfc1123 | ||
| // | ||
| //+kubebuilder:validation:Pattern:=^[a-z0-9]([-a-z0-9]*[a-z0-9])?$ | ||
| //+kubebuilder:validation:MaxLength:=63 | ||
| //+kubebuilder:validation:XValidation:rule="self == oldSelf",message="installNamespace is immutable" | ||
| @@ -140,11 +142,10 @@ type CatalogSource struct { | ||
| // packageName is a reference to the name of the package to be installed | ||
| // and is used to filter the content from catalogs. | ||
| // | ||
| // This field is required, immutable and follows the DNS label standard as defined in RFC | ||
| // 1123, with a deviation in the maximum length being no more than 48 | ||
| // characters. This means that valid values: | ||
| // - Contain no more than 48 characters | ||
| // - Contain only lowercase alphanumeric characters or '-' | ||
| // This field is required, immutable and follows the DNS subdomain name | ||
| // standard as defined in [RFC 1123]. This means that valid entries: | ||
| // - Contain no more than 253 characters | ||
| // - Contain only lowercase alphanumeric characters, '-', or '.' | ||
| // - Start with an alphanumeric character | ||
| // - End with an alphanumeric character | ||
| // | ||
| @@ -160,8 +161,10 @@ type CatalogSource struct { | ||
| // - thisisareallylongpackagenamethatisgreaterthanthemaximumlength | ||
| // - some.package | ||
| // | ||
| //+kubebuilder:validation:MaxLength:=48 | ||
| //+kubebuilder:validation:Pattern:=^[a-z0-9]+(-[a-z0-9]+)*$ | ||
| // [RFC 1123]: https://tools.ietf.org/html/rfc1123 | ||
| // | ||
| //+kubebuilder:validation:MaxLength:=253 | ||
| //+kubebuilder:validation:Pattern:=^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$ | ||
| //+kubebuilder:validation:XValidation:rule="self == oldSelf",message="packageName is immutable" | ||
| PackageName string `json:"packageName"` | ||
| @@ -259,10 +262,9 @@ type CatalogSource struct { | ||
| // | ||
| // When unspecified, upgrade edges across all channels will be used to identify valid automatic upgrade paths. | ||
| // | ||
| // This field follows the DNS subdomain name standard as defined in RFC | ||
| // 1123, with a deviation in the maximum length being no more than 48 | ||
| // characters. This means that valid values: | ||
| // - Contain no more than 48 characters | ||
| // This field follows the DNS subdomain name standard as defined in [RFC | ||
| // 1123]. This means that valid entries: | ||
| // - Contain no more than 253 characters | ||
| // - Contain only lowercase alphanumeric characters, '-', or '.' | ||
| // - Start with an alphanumeric character | ||
| // - End with an alphanumeric character | ||
| @@ -281,9 +283,13 @@ type CatalogSource struct { | ||
| // - -some-channel | ||
| // - some-channel- | ||
| // - thisisareallylongchannelnamethatisgreaterthanthemaximumlength | ||
| // - original_40 | ||
| // - --default-channel | ||
| // | ||
| // [RFC 1123]: https://tools.ietf.org/html/rfc1123 | ||
| // | ||
| //+kubebuilder:validation:MaxLength:=48 | ||
| //+kubebuilder:validation:Pattern:=^[a-z0-9]+([\.-][a-z0-9]+)*$ | ||
| //+kubebuilder:validation:MaxLength:=253 | ||
| //+kubebuilder:validation:Pattern:=^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$ | ||
| //+optional | ||
| Channel string `json:"channel,omitempty"` | ||
| @@ -329,8 +335,8 @@ type ServiceAccountReference struct { | ||
| // | ||
| // This ServiceAccount is expected to exist in the installNamespace. | ||
| // | ||
| // This field follows the DNS subdomain name standard as defined in RFC | ||
| // 1123. This means that valid values: | ||
| // This field follows the DNS subdomain name standard as defined in [RFC | ||
| // 1123]. This means that valid values: | ||
| // - Contain no more than 253 characters | ||
| // - Contain only lowercase alphanumeric characters, '-', or '.' | ||
| // - Start with an alphanumeric character | ||
| @@ -347,8 +353,10 @@ type ServiceAccountReference struct { | ||
| // - -some-serviceaccount | ||
| // - some-serviceaccount- | ||
| // | ||
| // [RFC 1123]: https://tools.ietf.org/html/rfc1123 | ||
| // | ||
| //+kubebuilder:validation:MaxLength:=253 | ||
| //+kubebuilder:validation:Pattern:=^[a-z0-9]+([.|-][a-z0-9]+)*$ | ||
| //+kubebuilder:validation:Pattern:=^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$ | ||
| //+kubebuilder:validation:XValidation:rule="self == oldSelf",message="name is immutable" | ||
| Name string `json:"name"` | ||
| } | ||
42 changes: 25 additions & 17 deletions
42 config/base/crd/bases/olm.operatorframework.io_clusterextensions.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
everettraven marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
Do the before or after changes from this PR align to the validations that happen in
opm validate? We need to make sure that package and channel names are fully specified and validated the exact same way in both places.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.
As far as I can tell, the validation for the package name does match. There does not appear to be any validation on channel names in
opm validate.IMO we should merge the validation changes here and then add the validation of the channel name to
opm validate.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 need to check known catalogs against these proposed validations before we merge so that we have more information to make a decision. We may ultimately decide to implement these validations despite breaking existing content, but we should know before we act.
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.
Gist that verified this validation works for all channel names in all known catalogs (except for one in the redhat certified operators index that looks like an unintentional channel name): https://gist.github.com/everettraven/4691c8cc6181f28b129f46cceeb602b5