-
Notifications
You must be signed in to change notification settings - Fork 277
/
spec.go
53 lines (44 loc) · 1.74 KB
/
spec.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package vsphere
import (
anywherev1 "github.com/aws/eks-anywhere/pkg/api/v1alpha1"
"github.com/aws/eks-anywhere/pkg/cluster"
)
type Spec struct {
*cluster.Spec
datacenterConfig *anywherev1.VSphereDatacenterConfig
machineConfigsLookup map[string]*anywherev1.VSphereMachineConfig
}
func NewSpec(clusterSpec *cluster.Spec, machineConfigs map[string]*anywherev1.VSphereMachineConfig, datacenterConfig *anywherev1.VSphereDatacenterConfig) *Spec {
machineConfigsInCluster := map[string]*anywherev1.VSphereMachineConfig{}
for _, m := range clusterSpec.MachineConfigRefs() {
machineConfig, ok := machineConfigs[m.Name]
if !ok {
continue
}
machineConfigsInCluster[m.Name] = machineConfig
}
return &Spec{
Spec: clusterSpec,
datacenterConfig: datacenterConfig,
machineConfigsLookup: machineConfigsInCluster,
}
}
func (s *Spec) controlPlaneMachineConfig() *anywherev1.VSphereMachineConfig {
return s.machineConfigsLookup[s.Cluster.Spec.ControlPlaneConfiguration.MachineGroupRef.Name]
}
func (s *Spec) workerMachineConfig(c anywherev1.WorkerNodeGroupConfiguration) *anywherev1.VSphereMachineConfig {
return s.machineConfigsLookup[c.MachineGroupRef.Name]
}
func (s *Spec) etcdMachineConfig() *anywherev1.VSphereMachineConfig {
if s.Cluster.Spec.ExternalEtcdConfiguration == nil || s.Cluster.Spec.ExternalEtcdConfiguration.MachineGroupRef == nil {
return nil
}
return s.machineConfigsLookup[s.Cluster.Spec.ExternalEtcdConfiguration.MachineGroupRef.Name]
}
func (s *Spec) machineConfigs() []*anywherev1.VSphereMachineConfig {
machineConfigs := make([]*anywherev1.VSphereMachineConfig, 0, len(s.machineConfigsLookup))
for _, m := range s.machineConfigsLookup {
machineConfigs = append(machineConfigs, m)
}
return machineConfigs
}