From 30e7a3253f310e7704aad50cc5baefb35370951b Mon Sep 17 00:00:00 2001 From: Stefan Bueringer Date: Tue, 20 May 2025 11:15:33 +0200 Subject: [PATCH] Fix pattern on Cluster classNamespace field MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stefan Büringer buringerst@vmware.com --- api/v1beta1/cluster_types.go | 12 +++++++----- api/v1beta1/zz_generated.openapi.go | 2 +- config/crd/bases/cluster.x-k8s.io_clusters.yaml | 12 +++++++----- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/api/v1beta1/cluster_types.go b/api/v1beta1/cluster_types.go index de6fba2843e1..be27ac6d1300 100644 --- a/api/v1beta1/cluster_types.go +++ b/api/v1beta1/cluster_types.go @@ -546,13 +546,15 @@ type Topology struct { // +kubebuilder:validation:MaxLength=253 Class string `json:"class"` - // classNamespace is the namespace of the ClusterClass object to create the topology. - // If the namespace is empty or not set, it is defaulted to the namespace of the cluster object. - // Value must follow the DNS1123Subdomain syntax. + // classNamespace is the namespace of the ClusterClass that should be used for the topology. + // If classNamespace is empty or not set, it is defaulted to the namespace of the Cluster object. + // classNamespace must be a valid namespace name and because of that be at most 63 characters in length + // and it must consist only of lower case alphanumeric characters or hyphens (-), and must start + // and end with an alphanumeric character. // +optional // +kubebuilder:validation:MinLength=1 - // +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:MaxLength=63 + // +kubebuilder:validation:Pattern=`^[a-z0-9]([-a-z0-9]*[a-z0-9])?$` ClassNamespace string `json:"classNamespace,omitempty"` // version is the Kubernetes version of the cluster. diff --git a/api/v1beta1/zz_generated.openapi.go b/api/v1beta1/zz_generated.openapi.go index 7793d65eb87e..a3f0529dc3ca 100644 --- a/api/v1beta1/zz_generated.openapi.go +++ b/api/v1beta1/zz_generated.openapi.go @@ -4678,7 +4678,7 @@ func schema_sigsk8sio_cluster_api_api_v1beta1_Topology(ref common.ReferenceCallb }, "classNamespace": { SchemaProps: spec.SchemaProps{ - Description: "classNamespace is the namespace of the ClusterClass object to create the topology. If the namespace is empty or not set, it is defaulted to the namespace of the cluster object. Value must follow the DNS1123Subdomain syntax.", + Description: "classNamespace is the namespace of the ClusterClass that should be used for the topology. If classNamespace is empty or not set, it is defaulted to the namespace of the Cluster object. classNamespace must be a valid namespace name and because of that be at most 63 characters in length and it must consist only of lower case alphanumeric characters or hyphens (-), and must start and end with an alphanumeric character.", Type: []string{"string"}, Format: "", }, diff --git a/config/crd/bases/cluster.x-k8s.io_clusters.yaml b/config/crd/bases/cluster.x-k8s.io_clusters.yaml index 8eb7748f6be6..2694d431cf02 100644 --- a/config/crd/bases/cluster.x-k8s.io_clusters.yaml +++ b/config/crd/bases/cluster.x-k8s.io_clusters.yaml @@ -967,12 +967,14 @@ spec: type: string classNamespace: description: |- - classNamespace is the namespace of the ClusterClass object to create the topology. - If the namespace is empty or not set, it is defaulted to the namespace of the cluster object. - Value must follow the DNS1123Subdomain syntax. - maxLength: 253 + classNamespace is the namespace of the ClusterClass that should be used for the topology. + If classNamespace is empty or not set, it is defaulted to the namespace of the Cluster object. + classNamespace must be a valid namespace name and because of that be at most 63 characters in length + and it must consist only of lower case alphanumeric characters or hyphens (-), and must start + and end with an alphanumeric character. + maxLength: 63 minLength: 1 - pattern: ^[a-z0-9](?:[-a-z0-9]*[a-z0-9])?(?:\.[a-z0-9](?:[-a-z0-9]*[a-z0-9])?)*$ + pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$ type: string controlPlane: description: controlPlane describes the cluster control plane.