Skip to content

Commit 19b6440

Browse files
authored
Merge pull request #3682 from Skarlso/remove-version-normalisation
Relax the AWSManagedControlPlane version regex and remove normalising the version
2 parents 7be67ad + cc6c57e commit 19b6440

File tree

4 files changed

+3
-22
lines changed

4 files changed

+3
-22
lines changed

config/crd/bases/controlplane.cluster.x-k8s.io_awsmanagedcontrolplanes.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2700,7 +2700,7 @@ spec:
27002700
version number is supplied then the latest version of Kubernetes
27012701
that EKS supports will be used.
27022702
minLength: 2
2703-
pattern: ^v(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.?$
2703+
pattern: ^v?(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.?(\.0|[1-9][0-9]*)?$
27042704
type: string
27052705
vpcCni:
27062706
description: VpcCni is used to set configuration options for the VPC

controlplane/eks/api/v1beta1/awsmanagedcontrolplane_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ type AWSManagedControlPlaneSpec struct { //nolint: maligned
6363
// is supplied then the latest version of Kubernetes that EKS supports
6464
// will be used.
6565
// +kubebuilder:validation:MinLength:=2
66-
// +kubebuilder:validation:Pattern:=^v(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.?$
66+
// +kubebuilder:validation:Pattern:=^v?(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.?(\.0|[1-9][0-9]*)?$
6767
// +optional
6868
Version *string `json:"version,omitempty"`
6969

controlplane/eks/api/v1beta1/awsmanagedcontrolplane_webhook.go

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,6 @@ func parseEKSVersion(raw string) (*version.Version, error) {
7070
return version.MustParseGeneric(fmt.Sprintf("%d.%d", v.Major(), v.Minor())), nil
7171
}
7272

73-
func normalizeVersion(raw string) (string, error) {
74-
// Normalize version (i.e. remove patch, add "v" prefix) if necessary
75-
eksV, err := parseEKSVersion(raw)
76-
if err != nil {
77-
return "", err
78-
}
79-
return fmt.Sprintf("v%d.%d", eksV.Major(), eksV.Minor()), nil
80-
}
81-
8273
// ValidateCreate will do any extra validation when creating a AWSManagedControlPlane.
8374
func (r *AWSManagedControlPlane) ValidateCreate() error {
8475
mcpLog.Info("AWSManagedControlPlane validate create", "name", r.Name)
@@ -376,16 +367,6 @@ func (r *AWSManagedControlPlane) Default() {
376367
}
377368
}
378369

379-
// Normalize version (i.e. remove patch, add "v" prefix) if necessary
380-
if r.Spec.Version != nil {
381-
normalizedV, err := normalizeVersion(*r.Spec.Version)
382-
if err != nil {
383-
mcpLog.Error(err, "couldn't parse version")
384-
return
385-
}
386-
r.Spec.Version = &normalizedV
387-
}
388-
389370
infrav1.SetDefaults_Bastion(&r.Spec.Bastion)
390371
infrav1.SetDefaults_NetworkSpec(&r.Spec.NetworkSpec)
391372
}

controlplane/eks/api/v1beta1/awsmanagedcontrolplane_webhook_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ func TestDefaultingWebhook(t *testing.T) {
105105
resourceNS: "default",
106106
expectHash: false,
107107
spec: AWSManagedControlPlaneSpec{Version: &vV1_17_1},
108-
expectSpec: AWSManagedControlPlaneSpec{EKSClusterName: "default_cluster1", Version: &vV1_17, IdentityRef: defaultIdentityRef, Bastion: defaultTestBastion, NetworkSpec: defaultNetworkSpec, TokenMethod: &EKSTokenMethodIAMAuthenticator},
108+
expectSpec: AWSManagedControlPlaneSpec{EKSClusterName: "default_cluster1", Version: &vV1_17_1, IdentityRef: defaultIdentityRef, Bastion: defaultTestBastion, NetworkSpec: defaultNetworkSpec, TokenMethod: &EKSTokenMethodIAMAuthenticator},
109109
},
110110
{
111111
name: "with allowed ip on bastion",

0 commit comments

Comments
 (0)