diff --git a/api/v1alpha1/addon_types.go b/api/v1alpha1/addon_types.go index 9395ff58e..ccc376c5e 100644 --- a/api/v1alpha1/addon_types.go +++ b/api/v1alpha1/addon_types.go @@ -6,17 +6,52 @@ package v1alpha1 import ( corev1 "k8s.io/api/core/v1" storagev1 "k8s.io/api/storage/v1" + + nutanixv1 "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/api/external/github.com/nutanix-cloud-native/cluster-api-provider-nutanix/api/v1beta1" ) +// All kubebuilder "Enum" build tag values are available in the OpenAPI spec. +// So that all these values are available to users of the api package, we +// we define a constant for each of the values. +// +// TODO: Generate these constants from the kubebuilder build tags, if possible. const ( - AddonStrategyClusterResourceSet AddonStrategy = "ClusterResourceSet" - AddonStrategyHelmAddon AddonStrategy = "HelmAddon" - VolumeBindingImmediate = storagev1.VolumeBindingImmediate - VolumeBindingWaitForFirstConsumer = storagev1.VolumeBindingWaitForFirstConsumer + CNIProviderCalico = "Calico" + CNIProviderCilium = "Cilium" + + CSIProviderAWSEBS = "aws-ebs" + CSIProviderNutanix = "nutanix" + + VirtualIPProviderKubeVIP = "KubeVIP" + + AddonStrategyClusterResourceSet AddonStrategy = "ClusterResourceSet" + AddonStrategyHelmAddon AddonStrategy = "HelmAddon" + + VolumeBindingImmediate = storagev1.VolumeBindingImmediate + VolumeBindingWaitForFirstConsumer = storagev1.VolumeBindingWaitForFirstConsumer VolumeReclaimRecycle = corev1.PersistentVolumeReclaimRecycle VolumeReclaimDelete = corev1.PersistentVolumeReclaimDelete VolumeReclaimRetain = corev1.PersistentVolumeReclaimRetain + + NutanixBootTypeLegacy = nutanixv1.NutanixBootTypeLegacy + NutanixBootTypeUEFI = nutanixv1.NutanixBootTypeUEFI +) + +// FIXME: Remove StorageProvisioner from the API. Users do not provide this +// value; we derive it from the CSI provider. +type StorageProvisioner string + +const ( + AWSEBSProvisioner StorageProvisioner = "ebs.csi.aws.com" + NutanixProvisioner StorageProvisioner = "csi.nutanix.com" +) + +// FIXME: Remove the CCM providers from the API. Users do not provider this +// value; we derive it from the cluster infrastructure. +const ( + CCMProviderAWS = "aws" + CCMProviderNutanix = "nutanix" ) type Addons struct { diff --git a/api/v1alpha1/clusterconfig_types.go b/api/v1alpha1/clusterconfig_types.go index caeb673af..6489ea63a 100644 --- a/api/v1alpha1/clusterconfig_types.go +++ b/api/v1alpha1/clusterconfig_types.go @@ -13,21 +13,6 @@ import ( "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/common/pkg/capi/clustertopology/variables" ) -type StorageProvisioner string - -const ( - CNIProviderCalico = "Calico" - CNIProviderCilium = "Cilium" - AWSEBSProvisioner StorageProvisioner = "ebs.csi.aws.com" - NutanixProvisioner StorageProvisioner = "csi.nutanix.com" - - CSIProviderAWSEBS = "aws-ebs" - CSIProviderNutanix = "nutanix" - - CCMProviderAWS = "aws" - CCMProviderNutanix = "nutanix" -) - var ( DefaultDockerCertSANs = []string{ "localhost", diff --git a/api/v1alpha1/common_types.go b/api/v1alpha1/common_types.go index 001e4d8c4..406f10fcc 100644 --- a/api/v1alpha1/common_types.go +++ b/api/v1alpha1/common_types.go @@ -3,12 +3,6 @@ package v1alpha1 -const ( - APIServerPort = 6443 - - VirtualIPProviderKubeVIP = "KubeVIP" -) - // ObjectMeta is metadata that all persisted resources must have, which includes all objects // users must create. This is a copy of customizable fields from metav1.ObjectMeta. // diff --git a/pkg/handlers/generic/lifecycle/ccm/handler.go b/pkg/handlers/generic/lifecycle/ccm/handler.go index 1403e319a..9145582ca 100644 --- a/pkg/handlers/generic/lifecycle/ccm/handler.go +++ b/pkg/handlers/generic/lifecycle/ccm/handler.go @@ -114,6 +114,7 @@ func (c *CCMHandler) AfterControlPlaneInitialized( return } + // There's a 1:1 mapping of infra to CCM provider. We derive the CCM provider from the infra. infraKind := req.Cluster.Spec.InfrastructureRef.Kind log.Info(fmt.Sprintf("finding CCM handler for %s", infraKind)) var handler CCMProvider diff --git a/pkg/handlers/generic/lifecycle/csi/handler.go b/pkg/handlers/generic/lifecycle/csi/handler.go index 2cd337e64..ab871bd73 100644 --- a/pkg/handlers/generic/lifecycle/csi/handler.go +++ b/pkg/handlers/generic/lifecycle/csi/handler.go @@ -111,6 +111,7 @@ func (c *CSIHandler) AfterControlPlaneInitialized( } } + // There's a 1:N mapping of infra to CSI providers. The user chooses the provider. for _, provider := range csiProviders.Providers { handler, ok := c.ProviderHandler[provider.Name] if !ok {