Skip to content

Commit

Permalink
fix: Fix the internal CluserConfig type used for provider-agnostic lo…
Browse files Browse the repository at this point in the history
…gic (#607)

Spotted in discussions with @dkoshkin about internal usage of types like
this as opposed to type switches.
  • Loading branch information
jimmidyson authored May 8, 2024
1 parent 9c452d5 commit 184abec
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion pkg/common/clusterconfig/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,31 @@ package clusterconfig

import carenv1 "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/api/v1alpha1"

// ClusterConfig is a type to be used internally to simplify the handling of cluster configurations for different
// providers. It is not meant to be used as a CRD.
// By including all the possible configurations for all the providers, we can easily switch between providers in code
// without type assertions/switches and avoids passing around `interface{}` or `any` types.
// Every provider-specific cluster config variable will successfully unmarshal to this type and so it is safe to use
// this internally when a handler provides functionality for multiple providers but exhibits different behaviour per
// provider.
type ClusterConfig struct {
AWS *carenv1.AWSSpec `json:"aws,omitempty"`

Docker *carenv1.AWSSpec `json:"doker,omitempty"`
Docker *carenv1.DockerSpec `json:"docker,omitempty"`

Nutanix *carenv1.NutanixSpec `json:"nutanix,omitempty"`

carenv1.GenericClusterConfigSpec `json:",inline"`

ExtraAPIServerCertSANs []string `json:"extraAPIServerCertSANs,omitempty"`

ControlPlane *ControlPlaneConfig `json:"controlPlane,omitempty"`
}

type ControlPlaneConfig struct {
AWS *carenv1.AWSControlPlaneNodeSpec `json:"aws,omitempty"`

Docker *carenv1.DockerNodeConfigSpec `json:"docker,omitempty"`

Nutanix *carenv1.NutanixNodeConfigSpec `json:"nutanix,omitempty"`
}

0 comments on commit 184abec

Please sign in to comment.