From 09ff82ef224a04d1300cbeed52fea75b2769bf59 Mon Sep 17 00:00:00 2001 From: Saurabh Parekh Date: Wed, 25 Dec 2024 11:57:12 -0800 Subject: [PATCH] Add license token string to cluster spec --- .../anywhere.eks.amazonaws.com_clusters.yaml | 2 + config/manifest/eksa-components.yaml | 9 ++++ pkg/api/v1alpha1/cluster_types.go | 4 ++ pkg/api/v1alpha1/cluster_types_test.go | 50 +++++++++++++++++++ 4 files changed, 65 insertions(+) diff --git a/config/crd/bases/anywhere.eks.amazonaws.com_clusters.yaml b/config/crd/bases/anywhere.eks.amazonaws.com_clusters.yaml index e26f02272568..c7d8e7862660 100644 --- a/config/crd/bases/anywhere.eks.amazonaws.com_clusters.yaml +++ b/config/crd/bases/anywhere.eks.amazonaws.com_clusters.yaml @@ -383,6 +383,8 @@ spec: type: array kubernetesVersion: type: string + licenseToken: + type: string machineHealthCheck: description: MachineHealthCheck allows to configure timeouts for machine health checks. Machine Health Checks are responsible for remediating diff --git a/config/manifest/eksa-components.yaml b/config/manifest/eksa-components.yaml index cb272f12bc16..76a384cc51d0 100644 --- a/config/manifest/eksa-components.yaml +++ b/config/manifest/eksa-components.yaml @@ -4273,6 +4273,8 @@ spec: type: array kubernetesVersion: type: string + licenseToken: + type: string machineHealthCheck: description: MachineHealthCheck allows to configure timeouts for machine health checks. Machine Health Checks are responsible for remediating @@ -5680,6 +5682,13 @@ spec: bundle for users that configured their Prism Central with certificates from non-publicly trusted CAs type: string + ccmExcludeNodeIPs: + description: CcmExcludeIPs is the optional list of IP addresses that + should be excluded from the CCM IP pool for nodes. List should be + valid IP addresses and IP address ranges. + items: + type: string + type: array credentialRef: description: CredentialRef is the reference to the secret name that contains the credentials for the Nutanix Prism Central. The namespace diff --git a/pkg/api/v1alpha1/cluster_types.go b/pkg/api/v1alpha1/cluster_types.go index 35a3b819fbb3..2b1467275645 100644 --- a/pkg/api/v1alpha1/cluster_types.go +++ b/pkg/api/v1alpha1/cluster_types.go @@ -87,6 +87,7 @@ type ClusterSpec struct { EksaVersion *EksaVersion `json:"eksaVersion,omitempty"` MachineHealthCheck *MachineHealthCheck `json:"machineHealthCheck,omitempty"` EtcdEncryption *[]EtcdEncryption `json:"etcdEncryption,omitempty"` + LicenseToken string `json:"licenseToken,omitempty"` } // EksaVersion is the semver identifying the release of eks-a used to populate the cluster components. @@ -185,6 +186,9 @@ func (n *Cluster) Equal(o *Cluster) bool { if !reflect.DeepEqual(n.Spec.EtcdEncryption, o.Spec.EtcdEncryption) { return false } + if n.Spec.LicenseToken != o.Spec.LicenseToken { + return false + } return true } diff --git a/pkg/api/v1alpha1/cluster_types_test.go b/pkg/api/v1alpha1/cluster_types_test.go index c479ec9f6acd..ff7fb37c4022 100644 --- a/pkg/api/v1alpha1/cluster_types_test.go +++ b/pkg/api/v1alpha1/cluster_types_test.go @@ -1494,6 +1494,56 @@ func TestClusterEqualDifferentBundlesRef(t *testing.T) { g.Expect(cluster1.Equal(cluster2)).To(BeFalse()) } +func TestClusterEqualLicenseToken(t *testing.T) { + testCases := []struct { + testName string + cluster1LicenseToken, cluster2LicenseToken string + want bool + }{ + { + testName: "both empty", + cluster1LicenseToken: "", + cluster2LicenseToken: "", + want: true, + }, + { + testName: "one empty, one exists", + cluster1LicenseToken: "", + cluster2LicenseToken: "test-token", + want: false, + }, + { + testName: "both exists, diff", + cluster1LicenseToken: "test-token1", + cluster2LicenseToken: "test-token2", + want: false, + }, + { + testName: "both exists, same", + cluster1LicenseToken: "test-token", + cluster2LicenseToken: "test-token", + want: true, + }, + } + for _, tt := range testCases { + t.Run(tt.testName, func(t *testing.T) { + cluster1 := &v1alpha1.Cluster{ + Spec: v1alpha1.ClusterSpec{ + LicenseToken: tt.cluster1LicenseToken, + }, + } + cluster2 := &v1alpha1.Cluster{ + Spec: v1alpha1.ClusterSpec{ + LicenseToken: tt.cluster2LicenseToken, + }, + } + + g := NewWithT(t) + g.Expect(cluster1.Equal(cluster2)).To(Equal(tt.want)) + }) + } +} + func TestControlPlaneConfigurationEqual(t *testing.T) { var emptyTaints []corev1.Taint taint1 := corev1.Taint{Key: "key1"}