diff --git a/api/v1alpha1/addon_types.go b/api/v1alpha1/addon_types.go index 7a0863bbf..c88edf1e7 100644 --- a/api/v1alpha1/addon_types.go +++ b/api/v1alpha1/addon_types.go @@ -20,7 +20,7 @@ type Addons struct { ClusterAutoscaler *ClusterAutoscaler `json:"clusterAutoscaler,omitempty"` // +optional - CPI *CPI `json:"cpi,omitempty"` + CCM *CCM `json:"ccm,omitempty"` // +optional CSIProviders *CSIProviders `json:"csi,omitempty"` @@ -36,7 +36,7 @@ func (Addons) VariableSchema() clusterv1.VariableSchema { "nfd": NFD{}.VariableSchema().OpenAPIV3Schema, "clusterAutoscaler": ClusterAutoscaler{}.VariableSchema().OpenAPIV3Schema, "csi": CSIProviders{}.VariableSchema().OpenAPIV3Schema, - "cpi": CPI{}.VariableSchema().OpenAPIV3Schema, + "ccm": CCM{}.VariableSchema().OpenAPIV3Schema, }, }, } @@ -173,10 +173,10 @@ func (CSIProviders) VariableSchema() clusterv1.VariableSchema { } } -// CPI tells us to enable or disable the cloud provider interface. -type CPI struct{} +// CCM tells us to enable or disable the cloud provider interface. +type CCM struct{} -func (CPI) VariableSchema() clusterv1.VariableSchema { +func (CCM) VariableSchema() clusterv1.VariableSchema { return clusterv1.VariableSchema{ OpenAPIV3Schema: clusterv1.JSONSchemaProps{ Type: "object", diff --git a/api/v1alpha1/clusterconfig_types.go b/api/v1alpha1/clusterconfig_types.go index 17e5b119e..7bbbef0d8 100644 --- a/api/v1alpha1/clusterconfig_types.go +++ b/api/v1alpha1/clusterconfig_types.go @@ -20,17 +20,17 @@ const ( CSIProviderAWSEBS = "aws-ebs" - CPIProviderAWS = "aws" + CCMProviderAWS = "aws" ) -//+kubebuilder:object:root=true +// +kubebuilder:object:root=true // ClusterConfig is the Schema for the clusterconfigs API. type ClusterConfig struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` - //+optional + // +optional Spec ClusterConfigSpec `json:"spec,omitempty"` } @@ -43,7 +43,7 @@ type ClusterConfigSpec struct { GenericClusterConfig `json:",inline"` - //+optional + // +optional ControlPlane *NodeConfigSpec `json:"controlPlane,omitempty"` } @@ -140,11 +140,11 @@ func (v KubernetesImageRepository) String() string { type Image struct { // Repository is used to override the image repository to pull from. - //+optional + // +optional Repository string `json:"repository,omitempty"` // Tag is used to override the default image tag. - //+optional + // +optional Tag string `json:"tag,omitempty"` } @@ -170,7 +170,7 @@ func (Image) VariableSchema() clusterv1.VariableSchema { type Etcd struct { // Image required for overriding etcd image details. - //+optional + // +optional Image *Image `json:"image,omitempty"` } diff --git a/api/v1alpha1/zz_generated.deepcopy.go b/api/v1alpha1/zz_generated.deepcopy.go index 5af92e536..01692d804 100644 --- a/api/v1alpha1/zz_generated.deepcopy.go +++ b/api/v1alpha1/zz_generated.deepcopy.go @@ -199,9 +199,9 @@ func (in *Addons) DeepCopyInto(out *Addons) { *out = new(ClusterAutoscaler) **out = **in } - if in.CPI != nil { - in, out := &in.CPI, &out.CPI - *out = new(CPI) + if in.CCM != nil { + in, out := &in.CCM, &out.CCM + *out = new(CCM) **out = **in } if in.CSIProviders != nil { @@ -222,31 +222,31 @@ func (in *Addons) DeepCopy() *Addons { } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *CNI) DeepCopyInto(out *CNI) { +func (in *CCM) DeepCopyInto(out *CCM) { *out = *in } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CNI. -func (in *CNI) DeepCopy() *CNI { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CCM. +func (in *CCM) DeepCopy() *CCM { if in == nil { return nil } - out := new(CNI) + out := new(CCM) in.DeepCopyInto(out) return out } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *CPI) DeepCopyInto(out *CPI) { +func (in *CNI) DeepCopyInto(out *CNI) { *out = *in } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CPI. -func (in *CPI) DeepCopy() *CPI { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CNI. +func (in *CNI) DeepCopy() *CNI { if in == nil { return nil } - out := new(CPI) + out := new(CNI) in.DeepCopyInto(out) return out } diff --git a/charts/cluster-api-runtime-extensions-nutanix/templates/cpi/aws/manifests/aws-cpi-v1.27.1-configmap.yaml b/charts/cluster-api-runtime-extensions-nutanix/templates/ccm/aws/manifests/aws-ccm-v1.27.1-configmap.yaml similarity index 97% rename from charts/cluster-api-runtime-extensions-nutanix/templates/cpi/aws/manifests/aws-cpi-v1.27.1-configmap.yaml rename to charts/cluster-api-runtime-extensions-nutanix/templates/ccm/aws/manifests/aws-ccm-v1.27.1-configmap.yaml index 7d34b818e..94f9739ce 100644 --- a/charts/cluster-api-runtime-extensions-nutanix/templates/cpi/aws/manifests/aws-cpi-v1.27.1-configmap.yaml +++ b/charts/cluster-api-runtime-extensions-nutanix/templates/ccm/aws/manifests/aws-ccm-v1.27.1-configmap.yaml @@ -3,11 +3,11 @@ #================================================================= # DO NOT EDIT THIS FILE -# IT HAS BEEN GENERATED BY /hack/addons/update-aws-cpi.sh +# IT HAS BEEN GENERATED BY /hack/addons/update-aws-ccm.sh #================================================================= apiVersion: v1 data: - aws-cpi-v1.27.1.yaml: | + aws-ccm-v1.27.1.yaml: | apiVersion: v1 kind: ServiceAccount metadata: @@ -185,4 +185,4 @@ data: kind: ConfigMap metadata: creationTimestamp: null - name: aws-cpi-v1.27.1 + name: aws-ccm-v1.27.1 diff --git a/charts/cluster-api-runtime-extensions-nutanix/templates/cpi/aws/manifests/aws-cpi-v1.28.1-configmap.yaml b/charts/cluster-api-runtime-extensions-nutanix/templates/ccm/aws/manifests/aws-ccm-v1.28.1-configmap.yaml similarity index 97% rename from charts/cluster-api-runtime-extensions-nutanix/templates/cpi/aws/manifests/aws-cpi-v1.28.1-configmap.yaml rename to charts/cluster-api-runtime-extensions-nutanix/templates/ccm/aws/manifests/aws-ccm-v1.28.1-configmap.yaml index 6a6b0d0f2..593b24c98 100644 --- a/charts/cluster-api-runtime-extensions-nutanix/templates/cpi/aws/manifests/aws-cpi-v1.28.1-configmap.yaml +++ b/charts/cluster-api-runtime-extensions-nutanix/templates/ccm/aws/manifests/aws-ccm-v1.28.1-configmap.yaml @@ -3,11 +3,11 @@ #================================================================= # DO NOT EDIT THIS FILE -# IT HAS BEEN GENERATED BY /hack/addons/update-aws-cpi.sh +# IT HAS BEEN GENERATED BY /hack/addons/update-aws-ccm.sh #================================================================= apiVersion: v1 data: - aws-cpi-v1.28.1.yaml: | + aws-ccm-v1.28.1.yaml: | apiVersion: v1 kind: ServiceAccount metadata: @@ -185,4 +185,4 @@ data: kind: ConfigMap metadata: creationTimestamp: null - name: aws-cpi-v1.28.1 + name: aws-ccm-v1.28.1 diff --git a/examples/capi-quick-start/aws-cluster-calico-crs.yaml b/examples/capi-quick-start/aws-cluster-calico-crs.yaml index d0bb44005..847222c10 100644 --- a/examples/capi-quick-start/aws-cluster-calico-crs.yaml +++ b/examples/capi-quick-start/aws-cluster-calico-crs.yaml @@ -21,12 +21,12 @@ spec: - name: clusterConfig value: addons: + ccm: {} clusterAutoscaler: strategy: ClusterResourceSet cni: provider: Calico strategy: ClusterResourceSet - cpi: {} csi: providers: - name: aws-ebs diff --git a/examples/capi-quick-start/aws-cluster-calico-helm-addon.yaml b/examples/capi-quick-start/aws-cluster-calico-helm-addon.yaml index de865c0a2..ac26e8051 100644 --- a/examples/capi-quick-start/aws-cluster-calico-helm-addon.yaml +++ b/examples/capi-quick-start/aws-cluster-calico-helm-addon.yaml @@ -21,12 +21,12 @@ spec: - name: clusterConfig value: addons: + ccm: {} clusterAutoscaler: strategy: HelmAddon cni: provider: Calico strategy: HelmAddon - cpi: {} csi: providers: - name: aws-ebs diff --git a/examples/capi-quick-start/aws-cluster-cilium-crs.yaml b/examples/capi-quick-start/aws-cluster-cilium-crs.yaml index 582498ec8..2fd77b867 100644 --- a/examples/capi-quick-start/aws-cluster-cilium-crs.yaml +++ b/examples/capi-quick-start/aws-cluster-cilium-crs.yaml @@ -21,12 +21,12 @@ spec: - name: clusterConfig value: addons: + ccm: {} clusterAutoscaler: strategy: ClusterResourceSet cni: provider: Cilium strategy: ClusterResourceSet - cpi: {} csi: providers: - name: aws-ebs diff --git a/examples/capi-quick-start/aws-cluster-cilium-helm-addon.yaml b/examples/capi-quick-start/aws-cluster-cilium-helm-addon.yaml index c710fa612..4bd929d2f 100644 --- a/examples/capi-quick-start/aws-cluster-cilium-helm-addon.yaml +++ b/examples/capi-quick-start/aws-cluster-cilium-helm-addon.yaml @@ -21,12 +21,12 @@ spec: - name: clusterConfig value: addons: + ccm: {} clusterAutoscaler: strategy: HelmAddon cni: provider: Cilium strategy: HelmAddon - cpi: {} csi: providers: - name: aws-ebs diff --git a/hack/addons/kustomize/aws-cpi/kustomization.yaml.tmpl b/hack/addons/kustomize/aws-ccm/kustomization.yaml.tmpl similarity index 86% rename from hack/addons/kustomize/aws-cpi/kustomization.yaml.tmpl rename to hack/addons/kustomize/aws-ccm/kustomization.yaml.tmpl index 3aff2a7e1..e8238d6da 100644 --- a/hack/addons/kustomize/aws-cpi/kustomization.yaml.tmpl +++ b/hack/addons/kustomize/aws-ccm/kustomization.yaml.tmpl @@ -5,13 +5,13 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization metadata: - name: aws-cpi-kustomize + name: aws-ccm-kustomize helmCharts: - name: aws-cloud-controller-manager repo: https://kubernetes.github.io/cloud-provider-aws releaseName: aws-cloud-controller-manager - version: ${AWS_CPI_CHART_VERSION} + version: ${AWS_CCM_CHART_VERSION} includeCRDs: true skipTests: true @@ -25,4 +25,4 @@ patches: images: - name: registry.k8s.io/provider-aws/cloud-controller-manager - newTag: ${AWS_CPI_VERSION} + newTag: ${AWS_CCM_VERSION} diff --git a/hack/addons/update-aws-cpi.sh b/hack/addons/update-aws-ccm.sh similarity index 60% rename from hack/addons/update-aws-cpi.sh rename to hack/addons/update-aws-ccm.sh index 1b00910c0..cee75151d 100755 --- a/hack/addons/update-aws-cpi.sh +++ b/hack/addons/update-aws-ccm.sh @@ -8,13 +8,13 @@ readonly SCRIPT_DIR # shellcheck source=hack/common.sh source "${SCRIPT_DIR}/../common.sh" -AWS_CPI_VERSION=$1 -export AWS_CPI_VERSION -AWS_CPI_CHART_VERSION=$2 -export AWS_CPI_CHART_VERSION +AWS_CCM_VERSION=$1 +export AWS_CCM_VERSION +AWS_CCM_CHART_VERSION=$2 +export AWS_CCM_CHART_VERSION -if [ -z "${AWS_CPI_VERSION:-}" ]; then - echo "Missing argument: AWS_CPI_VERSION" +if [ -z "${AWS_CCM_VERSION:-}" ]; then + echo "Missing argument: AWS_CCM_VERSION" exit 1 fi @@ -22,23 +22,23 @@ ASSETS_DIR="$(mktemp -d -p "${TMPDIR:-/tmp}")" readonly ASSETS_DIR trap_add "rm -rf ${ASSETS_DIR}" EXIT -readonly KUSTOMIZE_BASE_DIR="${SCRIPT_DIR}/kustomize/aws-cpi/" +readonly KUSTOMIZE_BASE_DIR="${SCRIPT_DIR}/kustomize/aws-ccm/" envsubst -no-unset <"${KUSTOMIZE_BASE_DIR}/kustomization.yaml.tmpl" >"${ASSETS_DIR}/kustomization.yaml" -readonly FILE_NAME="aws-cpi-${AWS_CPI_VERSION}.yaml" +readonly FILE_NAME="aws-ccm-${AWS_CCM_VERSION}.yaml" kustomize build --enable-helm "${ASSETS_DIR}" >"${ASSETS_DIR}/${FILE_NAME}" -kubectl create configmap aws-cpi-"${AWS_CPI_VERSION}" --dry-run=client --output yaml \ +kubectl create configmap aws-ccm-"${AWS_CCM_VERSION}" --dry-run=client --output yaml \ --from-file "${ASSETS_DIR}/${FILE_NAME}" \ - >"${ASSETS_DIR}/aws-cpi-${AWS_CPI_VERSION}-configmap.yaml" + >"${ASSETS_DIR}/aws-ccm-${AWS_CCM_VERSION}-configmap.yaml" # add warning not to edit file directly -cat <"${GIT_REPO_ROOT}/charts/cluster-api-runtime-extensions-nutanix/templates/cpi/aws/manifests/aws-cpi-${AWS_CPI_VERSION}-configmap.yaml" +cat <"${GIT_REPO_ROOT}/charts/cluster-api-runtime-extensions-nutanix/templates/ccm/aws/manifests/aws-ccm-${AWS_CCM_VERSION}-configmap.yaml" $(cat "${GIT_REPO_ROOT}/hack/license-header.yaml.txt") #================================================================= # DO NOT EDIT THIS FILE -# IT HAS BEEN GENERATED BY /hack/addons/update-aws-cpi.sh +# IT HAS BEEN GENERATED BY /hack/addons/update-aws-ccm.sh #================================================================= -$(cat "${ASSETS_DIR}/aws-cpi-${AWS_CPI_VERSION}-configmap.yaml") +$(cat "${ASSETS_DIR}/aws-ccm-${AWS_CCM_VERSION}-configmap.yaml") EOF diff --git a/hack/examples/bases/aws/cluster/kustomization.yaml.tmpl b/hack/examples/bases/aws/cluster/kustomization.yaml.tmpl index 10c970d1c..983a38473 100644 --- a/hack/examples/bases/aws/cluster/kustomization.yaml.tmpl +++ b/hack/examples/bases/aws/cluster/kustomization.yaml.tmpl @@ -35,7 +35,7 @@ patches: path: ../../../patches/cluster-autoscaler.yaml - target: kind: Cluster - path: ../../../patches/cpi.yaml + path: ../../../patches/ccm.yaml - target: kind: Cluster path: ../../../patches/aws/csi.yaml diff --git a/hack/examples/patches/cpi.yaml b/hack/examples/patches/ccm.yaml similarity index 67% rename from hack/examples/patches/cpi.yaml rename to hack/examples/patches/ccm.yaml index dff7b8841..3263fe97b 100644 --- a/hack/examples/patches/cpi.yaml +++ b/hack/examples/patches/ccm.yaml @@ -2,5 +2,5 @@ # SPDX-License-Identifier: Apache-2.0 - op: "add" - path: "/spec/topology/variables/0/value/addons/cpi" + path: "/spec/topology/variables/0/value/addons/ccm" value: {} diff --git a/make/addons.mk b/make/addons.mk index 60c04554f..85ad54575 100644 --- a/make/addons.mk +++ b/make/addons.mk @@ -7,14 +7,14 @@ export NODE_FEATURE_DISCOVERY_VERSION := $(shell goprintconst -file pkg/handlers export CLUSTER_AUTOSCALER_VERSION := 9.35.0 export AWS_CSI_SNAPSHOT_CONTROLLER_VERSION := v6.3.3 export AWS_EBS_CSI_CHART_VERSION := v2.28.1 -# a map of AWS CPI versions -export AWS_CPI_VERSION_127 := v1.27.1 -export AWS_CPI_CHART_VERSION_127 := 0.0.8 -export AWS_CPI_VERSION_128 := v1.28.1 -export AWS_CPI_CHART_VERSION_128 := 0.0.8 +# a map of AWS CCM versions +export AWS_CCM_VERSION_127 := v1.27.1 +export AWS_CCM_CHART_VERSION_127 := 0.0.8 +export AWS_CCM_VERSION_128 := v1.28.1 +export AWS_CCM_CHART_VERSION_128 := 0.0.8 .PHONY: addons.sync -addons.sync: $(addprefix update-addon.,calico cilium nfd cluster-autoscaler aws-ebs-csi aws-cpi.127 aws-cpi.128) +addons.sync: $(addprefix update-addon.,calico cilium nfd cluster-autoscaler aws-ebs-csi aws-ccm.127 aws-ccm.128) .PHONY: update-addon.calico update-addon.calico: ; $(info $(M) updating calico manifests) @@ -36,6 +36,6 @@ update-addon.cluster-autoscaler: ; $(info $(M) updating cluster-autoscaler manif update-addon.aws-ebs-csi: ; $(info $(M) updating aws ebs csi manifests) ./hack/addons/update-aws-ebs-csi.sh -.PHONY: update-addon.aws-cpi.% -update-addon.aws-cpi.%: ; $(info $(M) updating aws cpi $* manifests) - ./hack/addons/update-aws-cpi.sh $(AWS_CPI_VERSION_$*) $(AWS_CPI_CHART_VERSION_$*) +.PHONY: update-addon.aws-ccm.% +update-addon.aws-ccm.%: ; $(info $(M) updating aws ccm $* manifests) + ./hack/addons/update-aws-ccm.sh $(AWS_CCM_VERSION_$*) $(AWS_CCM_CHART_VERSION_$*) diff --git a/pkg/handlers/generic/lifecycle/cpi/aws/handler.go b/pkg/handlers/generic/lifecycle/ccm/aws/handler.go similarity index 56% rename from pkg/handlers/generic/lifecycle/cpi/aws/handler.go rename to pkg/handlers/generic/lifecycle/ccm/aws/handler.go index 3490af192..2e0e9225e 100644 --- a/pkg/handlers/generic/lifecycle/cpi/aws/handler.go +++ b/pkg/handlers/generic/lifecycle/ccm/aws/handler.go @@ -19,40 +19,40 @@ import ( "github.com/d2iq-labs/cluster-api-runtime-extensions-nutanix/pkg/handlers/options" ) -type AWSCPIConfig struct { +type AWSCCMConfig struct { *options.GlobalOptions - kubernetesMinorVersionToCPIConfigMapNames map[string]string + kubernetesMinorVersionToCCMConfigMapNames map[string]string } -func (a *AWSCPIConfig) AddFlags(prefix string, flags *pflag.FlagSet) { +func (a *AWSCCMConfig) AddFlags(prefix string, flags *pflag.FlagSet) { flags.StringToStringVar( - &a.kubernetesMinorVersionToCPIConfigMapNames, - prefix+".default-aws-cpi-configmap-names", + &a.kubernetesMinorVersionToCCMConfigMapNames, + prefix+".default-aws-ccm-configmap-names", map[string]string{ - "1.27": "aws-cpi-v1.27.1", - "1.28": "aws-cpi-v1.28.1", + "1.27": "aws-ccm-v1.27.1", + "1.28": "aws-ccm-v1.28.1", }, "map of provider cluster implementation type to default installation ConfigMap name", ) } -type AWSCPI struct { +type AWSCCM struct { client ctrlclient.Client - config *AWSCPIConfig + config *AWSCCMConfig } func New( c ctrlclient.Client, - cfg *AWSCPIConfig, -) *AWSCPI { - return &AWSCPI{ + cfg *AWSCCMConfig, +) *AWSCCM { + return &AWSCCM{ client: c, config: cfg, } } -func (a *AWSCPI) EnsureCPIConfigMapForCluster( +func (a *AWSCCM) EnsureCCMConfigMapForCluster( ctx context.Context, cluster *clusterv1.Cluster, ) (*corev1.ConfigMap, error) { @@ -60,56 +60,56 @@ func (a *AWSCPI) EnsureCPIConfigMapForCluster( "cluster", cluster.Name, ) - log.Info("Creating AWS CPI ConfigMap for Cluster") + log.Info("Creating AWS CCM ConfigMap for Cluster") version, err := semver.ParseTolerant(cluster.Spec.Topology.Version) if err != nil { return nil, fmt.Errorf("failed to parse version from cluster %w", err) } minorVersion := fmt.Sprintf("%d.%d", version.Major, version.Minor) - configMapForMinorVersion := a.config.kubernetesMinorVersionToCPIConfigMapNames[minorVersion] - cpiConfigMapForMinorVersion := &corev1.ConfigMap{ + configMapForMinorVersion := a.config.kubernetesMinorVersionToCCMConfigMapNames[minorVersion] + ccmConfigMapForMinorVersion := &corev1.ConfigMap{ ObjectMeta: metav1.ObjectMeta{ Namespace: a.config.DefaultsNamespace(), Name: configMapForMinorVersion, }, } objName := ctrlclient.ObjectKeyFromObject( - cpiConfigMapForMinorVersion, + ccmConfigMapForMinorVersion, ) - err = a.client.Get(ctx, objName, cpiConfigMapForMinorVersion) + err = a.client.Get(ctx, objName, ccmConfigMapForMinorVersion) if err != nil { - log.Error(err, "failed to fetch CPI template for cluster") + log.Error(err, "failed to fetch CCM template for cluster") return nil, fmt.Errorf( - "failed to retrieve default AWS CPI manifests ConfigMap %q: %w", + "failed to retrieve default AWS CCM manifests ConfigMap %q: %w", objName, err, ) } - cpiConfigMap := generateCPIConfigMapForCluster(cpiConfigMapForMinorVersion, cluster) - if err := client.ServerSideApply(ctx, a.client, cpiConfigMap); err != nil { - log.Error(err, "failed to apply CPI configmap for cluster") + ccmConfigMap := generateCCMConfigMapForCluster(ccmConfigMapForMinorVersion, cluster) + if err := client.ServerSideApply(ctx, a.client, ccmConfigMap); err != nil { + log.Error(err, "failed to apply CCM configmap for cluster") return nil, fmt.Errorf( - "failed to apply AWS CPI manifests ConfigMap: %w", + "failed to apply AWS CCM manifests ConfigMap: %w", err, ) } - return cpiConfigMap, nil + return ccmConfigMap, nil } -func generateCPIConfigMapForCluster( - cpiConfigMapForVersion *corev1.ConfigMap, cluster *clusterv1.Cluster, +func generateCCMConfigMapForCluster( + ccmConfigMapForVersion *corev1.ConfigMap, cluster *clusterv1.Cluster, ) *corev1.ConfigMap { - cpiConfigMapForCluster := &corev1.ConfigMap{ + ccmConfigMapForCluster := &corev1.ConfigMap{ TypeMeta: metav1.TypeMeta{ APIVersion: corev1.SchemeGroupVersion.String(), Kind: "ConfigMap", }, ObjectMeta: metav1.ObjectMeta{ Namespace: cluster.Namespace, - Name: fmt.Sprintf("%s-%s", cpiConfigMapForVersion.Name, cluster.Name), + Name: fmt.Sprintf("%s-%s", ccmConfigMapForVersion.Name, cluster.Name), }, - Data: cpiConfigMapForVersion.Data, + Data: ccmConfigMapForVersion.Data, } - return cpiConfigMapForCluster + return ccmConfigMapForCluster } diff --git a/pkg/handlers/generic/lifecycle/cpi/aws/handler_test.go b/pkg/handlers/generic/lifecycle/ccm/aws/handler_test.go similarity index 89% rename from pkg/handlers/generic/lifecycle/cpi/aws/handler_test.go rename to pkg/handlers/generic/lifecycle/ccm/aws/handler_test.go index 0fd559f5e..de34b4bae 100644 --- a/pkg/handlers/generic/lifecycle/cpi/aws/handler_test.go +++ b/pkg/handlers/generic/lifecycle/ccm/aws/handler_test.go @@ -12,7 +12,7 @@ import ( clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" ) -var startAWSCPIConfigMap = ` +var startAWSCCMConfigMap = ` apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: @@ -77,7 +77,7 @@ spec: type: RollingUpdate ` -func Test_generateCPIConfigMapForCluster(t *testing.T) { +func Test_generateCCMConfigMapForCluster(t *testing.T) { tests := []struct { name string startConfigMap *corev1.ConfigMap @@ -87,11 +87,11 @@ func Test_generateCPIConfigMapForCluster(t *testing.T) { name: "Can set cluster name in arguments", startConfigMap: &corev1.ConfigMap{ ObjectMeta: metav1.ObjectMeta{ - Name: "aws-cpi-v1.27.1", + Name: "aws-ccm-v1.27.1", Namespace: "default", }, Data: map[string]string{ - "aws-cpi-v1.27.1.yaml": startAWSCPIConfigMap, + "aws-ccm-v1.27.1.yaml": startAWSCCMConfigMap, }, }, cluster: &clusterv1.Cluster{ @@ -104,19 +104,19 @@ func Test_generateCPIConfigMapForCluster(t *testing.T) { } for _, test := range tests { t.Run(test.name, func(t *testing.T) { - cm := generateCPIConfigMapForCluster( + cm := generateCCMConfigMapForCluster( test.startConfigMap, test.cluster, ) - cpiConfigMapExpectedName := fmt.Sprintf( + ccmConfigMapExpectedName := fmt.Sprintf( "%s-%s", test.startConfigMap.Name, test.cluster.Name, ) - if cm.Name != cpiConfigMapExpectedName { + if cm.Name != ccmConfigMapExpectedName { t.Errorf( "expected configmap name to be %s. got: %s", - cpiConfigMapExpectedName, + ccmConfigMapExpectedName, cm.Name, ) } diff --git a/pkg/handlers/generic/lifecycle/cpi/doc.go b/pkg/handlers/generic/lifecycle/ccm/doc.go similarity index 98% rename from pkg/handlers/generic/lifecycle/cpi/doc.go rename to pkg/handlers/generic/lifecycle/ccm/doc.go index 10ac8b7f3..8fe9f0035 100644 --- a/pkg/handlers/generic/lifecycle/cpi/doc.go +++ b/pkg/handlers/generic/lifecycle/ccm/doc.go @@ -9,4 +9,4 @@ // // +kubebuilder:rbac:groups=addons.cluster.x-k8s.io,resources=clusterresourcesets,verbs=watch;list;get;create;patch;update;delete // +kubebuilder:rbac:groups="",resources=configmaps,verbs=watch;list;get;create;patch;update;delete -package cpi +package ccm diff --git a/pkg/handlers/generic/lifecycle/cpi/handler.go b/pkg/handlers/generic/lifecycle/ccm/handler.go similarity index 66% rename from pkg/handlers/generic/lifecycle/cpi/handler.go rename to pkg/handlers/generic/lifecycle/ccm/handler.go index e9e1237ed..43360aa1b 100644 --- a/pkg/handlers/generic/lifecycle/cpi/handler.go +++ b/pkg/handlers/generic/lifecycle/ccm/handler.go @@ -1,7 +1,7 @@ // Copyright 2023 D2iQ, Inc. All rights reserved. // SPDX-License-Identifier: Apache-2.0 -package cpi +package ccm import ( "context" @@ -23,30 +23,30 @@ import ( ) const ( - variableRootName = "cpi" + variableRootName = "ccm" ) -type CPIProvider interface { - EnsureCPIConfigMapForCluster(context.Context, *clusterv1.Cluster) (*corev1.ConfigMap, error) +type CCMProvider interface { + EnsureCCMConfigMapForCluster(context.Context, *clusterv1.Cluster) (*corev1.ConfigMap, error) } -type CPIHandler struct { +type CCMHandler struct { client ctrlclient.Client variableName string variablePath []string - ProviderHandler map[string]CPIProvider + ProviderHandler map[string]CCMProvider } var ( - _ commonhandlers.Named = &CPIHandler{} - _ lifecycle.AfterControlPlaneInitialized = &CPIHandler{} + _ commonhandlers.Named = &CCMHandler{} + _ lifecycle.AfterControlPlaneInitialized = &CCMHandler{} ) func New( c ctrlclient.Client, - handlers map[string]CPIProvider, -) *CPIHandler { - return &CPIHandler{ + handlers map[string]CCMProvider, +) *CCMHandler { + return &CCMHandler{ client: c, variableName: clusterconfig.MetaVariableName, variablePath: []string{"addons", variableRootName}, @@ -54,11 +54,11 @@ func New( } } -func (c *CPIHandler) Name() string { - return "CPIHandler" +func (c *CCMHandler) Name() string { + return "CCMHandler" } -func (c *CPIHandler) AfterControlPlaneInitialized( +func (c *CCMHandler) AfterControlPlaneInitialized( ctx context.Context, req *runtimehooksv1.AfterControlPlaneInitializedRequest, resp *runtimehooksv1.AfterControlPlaneInitializedResponse, @@ -72,43 +72,43 @@ func (c *CPIHandler) AfterControlPlaneInitialized( varMap := variables.ClusterVariablesToVariablesMap(req.Cluster.Spec.Topology.Variables) - _, found, err := variables.Get[v1alpha1.CPI](varMap, c.variableName, c.variablePath...) + _, found, err := variables.Get[v1alpha1.CCM](varMap, c.variableName, c.variablePath...) if err != nil { log.Error( err, - "failed to read CPI from cluster definition", + "failed to read CCM from cluster definition", ) resp.SetStatus(runtimehooksv1.ResponseStatusFailure) resp.SetMessage( - fmt.Sprintf("failed to read CPI provider from cluster definition: %v", + fmt.Sprintf("failed to read CCM provider from cluster definition: %v", err, ), ) return } if !found { - log.V(4).Info("Skipping CPI handler.") + log.V(4).Info("Skipping CCM handler.") return } infraKind := req.Cluster.Spec.InfrastructureRef.Kind - log.Info(fmt.Sprintf("finding cpi handler for %s", infraKind)) - var handler CPIProvider + log.Info(fmt.Sprintf("finding CCM handler for %s", infraKind)) + var handler CCMProvider switch { - case strings.Contains(strings.ToLower(infraKind), v1alpha1.CPIProviderAWS): - handler = c.ProviderHandler[v1alpha1.CPIProviderAWS] + case strings.Contains(strings.ToLower(infraKind), v1alpha1.CCMProviderAWS): + handler = c.ProviderHandler[v1alpha1.CCMProviderAWS] default: - log.Info(fmt.Sprintf("No CPI handler provided for infra kind %s", infraKind)) + log.Info(fmt.Sprintf("No CCM handler provided for infra kind %s", infraKind)) return } - cm, err := handler.EnsureCPIConfigMapForCluster(ctx, &req.Cluster) + cm, err := handler.EnsureCCMConfigMapForCluster(ctx, &req.Cluster) if err != nil { log.Error( err, - "failed to generate CPI configmap", + "failed to generate CCM configmap", ) resp.SetStatus(runtimehooksv1.ResponseStatusFailure) resp.SetMessage( - fmt.Sprintf("failed to generate CPI configmap: %v", + fmt.Sprintf("failed to generate CCM configmap: %v", err, ), ) @@ -118,11 +118,11 @@ func (c *CPIHandler) AfterControlPlaneInitialized( if err != nil { log.Error( err, - "failed to generate CPI CRS for cluster", + "failed to generate CCM CRS for cluster", ) resp.SetStatus(runtimehooksv1.ResponseStatusFailure) resp.SetMessage( - fmt.Sprintf("failed to generate CPI CRS: %v", + fmt.Sprintf("failed to generate CCM CRS: %v", err, ), ) diff --git a/pkg/handlers/generic/lifecycle/handlers.go b/pkg/handlers/generic/lifecycle/handlers.go index fcfc07d10..366e78196 100644 --- a/pkg/handlers/generic/lifecycle/handlers.go +++ b/pkg/handlers/generic/lifecycle/handlers.go @@ -9,11 +9,11 @@ import ( "github.com/d2iq-labs/cluster-api-runtime-extensions-nutanix/api/v1alpha1" "github.com/d2iq-labs/cluster-api-runtime-extensions-nutanix/common/pkg/capi/clustertopology/handlers" + "github.com/d2iq-labs/cluster-api-runtime-extensions-nutanix/pkg/handlers/generic/lifecycle/ccm" + awsccm "github.com/d2iq-labs/cluster-api-runtime-extensions-nutanix/pkg/handlers/generic/lifecycle/ccm/aws" "github.com/d2iq-labs/cluster-api-runtime-extensions-nutanix/pkg/handlers/generic/lifecycle/clusterautoscaler" "github.com/d2iq-labs/cluster-api-runtime-extensions-nutanix/pkg/handlers/generic/lifecycle/cni/calico" "github.com/d2iq-labs/cluster-api-runtime-extensions-nutanix/pkg/handlers/generic/lifecycle/cni/cilium" - "github.com/d2iq-labs/cluster-api-runtime-extensions-nutanix/pkg/handlers/generic/lifecycle/cpi" - awscpi "github.com/d2iq-labs/cluster-api-runtime-extensions-nutanix/pkg/handlers/generic/lifecycle/cpi/aws" "github.com/d2iq-labs/cluster-api-runtime-extensions-nutanix/pkg/handlers/generic/lifecycle/csi" awsebs "github.com/d2iq-labs/cluster-api-runtime-extensions-nutanix/pkg/handlers/generic/lifecycle/csi/aws-ebs" "github.com/d2iq-labs/cluster-api-runtime-extensions-nutanix/pkg/handlers/generic/lifecycle/nfd" @@ -27,7 +27,7 @@ type Handlers struct { nfdConfig *nfd.Config clusterAutoscalerConfig *clusterautoscaler.Config ebsConfig *awsebs.AWSEBSConfig - awsCPIConfig *awscpi.AWSCPIConfig + awsccmConfig *awsccm.AWSCCMConfig } func New(globalOptions *options.GlobalOptions) *Handlers { @@ -37,7 +37,7 @@ func New(globalOptions *options.GlobalOptions) *Handlers { nfdConfig: &nfd.Config{GlobalOptions: globalOptions}, clusterAutoscalerConfig: &clusterautoscaler.Config{GlobalOptions: globalOptions}, ebsConfig: &awsebs.AWSEBSConfig{GlobalOptions: globalOptions}, - awsCPIConfig: &awscpi.AWSCPIConfig{GlobalOptions: globalOptions}, + awsccmConfig: &awsccm.AWSCCMConfig{GlobalOptions: globalOptions}, } } @@ -45,8 +45,8 @@ func (h *Handlers) AllHandlers(mgr manager.Manager) []handlers.Named { csiHandlers := map[string]csi.CSIProvider{ v1alpha1.CSIProviderAWSEBS: awsebs.New(mgr.GetClient(), h.ebsConfig), } - cpiHandlers := map[string]cpi.CPIProvider{ - v1alpha1.CPIProviderAWS: awscpi.New(mgr.GetClient(), h.awsCPIConfig), + ccmHandlers := map[string]ccm.CCMProvider{ + v1alpha1.CCMProviderAWS: awsccm.New(mgr.GetClient(), h.awsccmConfig), } return []handlers.Named{ @@ -56,7 +56,7 @@ func (h *Handlers) AllHandlers(mgr manager.Manager) []handlers.Named { clusterautoscaler.New(mgr.GetClient(), h.clusterAutoscalerConfig), servicelbgc.New(mgr.GetClient()), csi.New(mgr.GetClient(), csiHandlers), - cpi.New(mgr.GetClient(), cpiHandlers), + ccm.New(mgr.GetClient(), ccmHandlers), } } @@ -66,5 +66,5 @@ func (h *Handlers) AddFlags(flagSet *pflag.FlagSet) { h.calicoCNIConfig.AddFlags("cni.calico", flagSet) h.ciliumCNIConfig.AddFlags("cni.cilium", flagSet) h.ebsConfig.AddFlags("awsebs", pflag.CommandLine) - h.awsCPIConfig.AddFlags("awscpi", pflag.CommandLine) + h.awsccmConfig.AddFlags("awsccm", pflag.CommandLine) }