Skip to content

Commit 184abec

Browse files
authored
fix: Fix the internal CluserConfig type used for provider-agnostic logic (#607)
Spotted in discussions with @dkoshkin about internal usage of types like this as opposed to type switches.
1 parent 9c452d5 commit 184abec

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

pkg/common/clusterconfig/types.go

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,31 @@ package clusterconfig
55

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

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

11-
Docker *carenv1.AWSSpec `json:"doker,omitempty"`
18+
Docker *carenv1.DockerSpec `json:"docker,omitempty"`
1219

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

1522
carenv1.GenericClusterConfigSpec `json:",inline"`
23+
24+
ExtraAPIServerCertSANs []string `json:"extraAPIServerCertSANs,omitempty"`
25+
26+
ControlPlane *ControlPlaneConfig `json:"controlPlane,omitempty"`
27+
}
28+
29+
type ControlPlaneConfig struct {
30+
AWS *carenv1.AWSControlPlaneNodeSpec `json:"aws,omitempty"`
31+
32+
Docker *carenv1.DockerNodeConfigSpec `json:"docker,omitempty"`
33+
34+
Nutanix *carenv1.NutanixNodeConfigSpec `json:"nutanix,omitempty"`
1635
}

0 commit comments

Comments
 (0)