Skip to content

Commit

Permalink
Merge pull request #3682 from Skarlso/remove-version-normalisation
Browse files Browse the repository at this point in the history
Relax the AWSManagedControlPlane version regex and remove normalising the version
  • Loading branch information
k8s-ci-robot authored Sep 2, 2022
2 parents 7be67ad + cc6c57e commit 19b6440
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2700,7 +2700,7 @@ spec:
version number is supplied then the latest version of Kubernetes
that EKS supports will be used.
minLength: 2
pattern: ^v(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.?$
pattern: ^v?(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.?(\.0|[1-9][0-9]*)?$
type: string
vpcCni:
description: VpcCni is used to set configuration options for the VPC
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ type AWSManagedControlPlaneSpec struct { //nolint: maligned
// is supplied then the latest version of Kubernetes that EKS supports
// will be used.
// +kubebuilder:validation:MinLength:=2
// +kubebuilder:validation:Pattern:=^v(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.?$
// +kubebuilder:validation:Pattern:=^v?(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.?(\.0|[1-9][0-9]*)?$
// +optional
Version *string `json:"version,omitempty"`

Expand Down
19 changes: 0 additions & 19 deletions controlplane/eks/api/v1beta1/awsmanagedcontrolplane_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,6 @@ func parseEKSVersion(raw string) (*version.Version, error) {
return version.MustParseGeneric(fmt.Sprintf("%d.%d", v.Major(), v.Minor())), nil
}

func normalizeVersion(raw string) (string, error) {
// Normalize version (i.e. remove patch, add "v" prefix) if necessary
eksV, err := parseEKSVersion(raw)
if err != nil {
return "", err
}
return fmt.Sprintf("v%d.%d", eksV.Major(), eksV.Minor()), nil
}

// ValidateCreate will do any extra validation when creating a AWSManagedControlPlane.
func (r *AWSManagedControlPlane) ValidateCreate() error {
mcpLog.Info("AWSManagedControlPlane validate create", "name", r.Name)
Expand Down Expand Up @@ -376,16 +367,6 @@ func (r *AWSManagedControlPlane) Default() {
}
}

// Normalize version (i.e. remove patch, add "v" prefix) if necessary
if r.Spec.Version != nil {
normalizedV, err := normalizeVersion(*r.Spec.Version)
if err != nil {
mcpLog.Error(err, "couldn't parse version")
return
}
r.Spec.Version = &normalizedV
}

infrav1.SetDefaults_Bastion(&r.Spec.Bastion)
infrav1.SetDefaults_NetworkSpec(&r.Spec.NetworkSpec)
}
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func TestDefaultingWebhook(t *testing.T) {
resourceNS: "default",
expectHash: false,
spec: AWSManagedControlPlaneSpec{Version: &vV1_17_1},
expectSpec: AWSManagedControlPlaneSpec{EKSClusterName: "default_cluster1", Version: &vV1_17, IdentityRef: defaultIdentityRef, Bastion: defaultTestBastion, NetworkSpec: defaultNetworkSpec, TokenMethod: &EKSTokenMethodIAMAuthenticator},
expectSpec: AWSManagedControlPlaneSpec{EKSClusterName: "default_cluster1", Version: &vV1_17_1, IdentityRef: defaultIdentityRef, Bastion: defaultTestBastion, NetworkSpec: defaultNetworkSpec, TokenMethod: &EKSTokenMethodIAMAuthenticator},
},
{
name: "with allowed ip on bastion",
Expand Down

0 comments on commit 19b6440

Please sign in to comment.