@@ -16,19 +16,28 @@ import (
1616 "github.com/openshift/installer/pkg/types/aws"
1717)
1818
19+ // MachineInput defines the inputs needed to generate a machine asset.
20+ type MachineInput struct {
21+ Role string
22+ Pool * types.MachinePool
23+ Subnets map [string ]string
24+ Tags map [string ]string
25+ PublicIP bool
26+ }
27+
1928// GenerateMachines returns manifests and runtime objects to provision the control plane (including bootstrap, if applicable) nodes using CAPI.
20- func GenerateMachines (clusterID string , region string , subnets map [ string ] string , pool * types. MachinePool , role string , userTags map [ string ] string ) ([]* asset.RuntimeFile , error ) {
21- if poolPlatform := pool .Platform .Name (); poolPlatform != aws .Name {
29+ func GenerateMachines (clusterID string , in * MachineInput ) ([]* asset.RuntimeFile , error ) {
30+ if poolPlatform := in . Pool .Platform .Name (); poolPlatform != aws .Name {
2231 return nil , fmt .Errorf ("non-AWS machine-pool: %q" , poolPlatform )
2332 }
24- mpool := pool .Platform .AWS
33+ mpool := in . Pool .Platform .AWS
2534
2635 total := int64 (1 )
27- if pool .Replicas != nil {
28- total = * pool .Replicas
36+ if in . Pool .Replicas != nil {
37+ total = * in . Pool .Replicas
2938 }
3039
31- tags , err := CapaTagsFromUserTags (clusterID , userTags )
40+ tags , err := CapaTagsFromUserTags (clusterID , in . Tags )
3241 if err != nil {
3342 return nil , fmt .Errorf ("failed to create machineapi.TagSpecifications from UserTags: %w" , err )
3443 }
@@ -37,8 +46,8 @@ func GenerateMachines(clusterID string, region string, subnets map[string]string
3746
3847 for idx := int64 (0 ); idx < total ; idx ++ {
3948 zone := mpool .Zones [int (idx )% len (mpool .Zones )]
40- subnetID , ok := subnets [zone ]
41- if len (subnets ) > 0 && ! ok {
49+ subnetID , ok := in . Subnets [zone ]
50+ if len (in . Subnets ) > 0 && ! ok {
4251 return nil , fmt .Errorf ("no subnet for zone %s" , zone )
4352 }
4453 subnet := & capa.AWSResourceReference {}
@@ -55,7 +64,7 @@ func GenerateMachines(clusterID string, region string, subnets map[string]string
5564
5665 awsMachine := & capa.AWSMachine {
5766 ObjectMeta : metav1.ObjectMeta {
58- Name : fmt .Sprintf ("%s-%s-%d" , clusterID , pool .Name , idx ),
67+ Name : fmt .Sprintf ("%s-%s-%d" , clusterID , in . Pool .Name , idx ),
5968 Labels : map [string ]string {
6069 "cluster.x-k8s.io/control-plane" : "" ,
6170 },
@@ -103,7 +112,7 @@ func GenerateMachines(clusterID string, region string, subnets map[string]string
103112 Spec : capi.MachineSpec {
104113 ClusterName : clusterID ,
105114 Bootstrap : capi.Bootstrap {
106- DataSecretName : ptr .To (fmt .Sprintf ("%s-%s" , clusterID , role )),
115+ DataSecretName : ptr .To (fmt .Sprintf ("%s-%s" , clusterID , in . Role )),
107116 },
108117 InfrastructureRef : v1.ObjectReference {
109118 APIVersion : capa .GroupVersion .String (),
0 commit comments