Skip to content

refactor: Clean up API constants, and explain usage #588

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 39 additions & 4 deletions api/v1alpha1/addon_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
15 changes: 0 additions & 15 deletions api/v1alpha1/clusterconfig_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
6 changes: 0 additions & 6 deletions api/v1alpha1/common_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
//
Expand Down
1 change: 1 addition & 0 deletions pkg/handlers/generic/lifecycle/ccm/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions pkg/handlers/generic/lifecycle/csi/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Loading