@@ -17,8 +17,10 @@ import (
1717 "sigs.k8s.io/controller-runtime/pkg/client"
1818 "sigs.k8s.io/controller-runtime/pkg/envtest"
1919
20+ "github.com/openshift/installer/cmd/openshift-install/command"
2021 "github.com/openshift/installer/data"
21- "github.com/openshift/installer/pkg/asset/installconfig"
22+ "github.com/openshift/installer/pkg/asset/cluster/metadata"
23+ azic "github.com/openshift/installer/pkg/asset/installconfig/azure"
2224 gcpic "github.com/openshift/installer/pkg/asset/installconfig/gcp"
2325 powervsic "github.com/openshift/installer/pkg/asset/installconfig/powervs"
2426 "github.com/openshift/installer/pkg/clusterapi/internal/process"
@@ -49,7 +51,7 @@ const (
4951
5052// Interface is the interface for the cluster-api system.
5153type Interface interface {
52- Run (ctx context.Context , installConfig * installconfig. InstallConfig ) error
54+ Run (ctx context.Context ) error
5355 State () SystemState
5456 Client () client.Client
5557 Teardown ()
@@ -78,7 +80,7 @@ type system struct {
7880}
7981
8082// Run launches the cluster-api system.
81- func (c * system ) Run (ctx context.Context , installConfig * installconfig. InstallConfig ) error {
83+ func (c * system ) Run (ctx context.Context ) error {
8284 c .Lock ()
8385 defer c .Unlock ()
8486
@@ -121,9 +123,19 @@ func (c *system) Run(ctx context.Context, installConfig *installconfig.InstallCo
121123 },
122124 }
123125
126+ metadata , err := metadata .Load (command .RootOpts .Dir )
127+ if err != nil {
128+ return fmt .Errorf ("failed to load metadata: %w" , err )
129+ }
130+
131+ platform := metadata .Platform ()
132+ if platform == "" {
133+ return fmt .Errorf ("no platform configured in metadata" )
134+ }
135+
124136 // Create the infrastructure controllers.
125137 // Only add the controllers for the platform we are deploying to.
126- switch platform := installConfig . Config . Platform . Name (); platform {
138+ switch platform {
127139 case aws .Name :
128140 controller := c .getInfrastructureController (
129141 & AWS ,
@@ -137,7 +149,7 @@ func (c *system) Run(ctx context.Context, installConfig *installconfig.InstallCo
137149 },
138150 map [string ]string {},
139151 )
140- if cfg := installConfig . Config .AWS ; cfg != nil && len (cfg .ServiceEndpoints ) > 0 {
152+ if cfg := metadata .AWS ; cfg != nil && len (cfg .ServiceEndpoints ) > 0 {
141153 endpoints := make ([]string , 0 , len (cfg .ServiceEndpoints ))
142154 // CAPA expects name=url pairs of service endpoints
143155 for _ , endpoint := range cfg .ServiceEndpoints {
@@ -147,9 +159,13 @@ func (c *system) Run(ctx context.Context, installConfig *installconfig.InstallCo
147159 }
148160 controllers = append (controllers , controller )
149161 case azure .Name :
150- session , err := installConfig .Azure .Session ()
162+ cloudName := metadata .Azure .CloudName
163+ if cloudName == "" {
164+ cloudName = azure .PublicCloud
165+ }
166+ session , err := azic .GetSession (cloudName , metadata .Azure .ARMEndpoint )
151167 if err != nil {
152- return fmt .Errorf ("failed to create azure session: %w" , err )
168+ return fmt .Errorf ("unable to retrieve azure session: %w" , err )
153169 }
154170
155171 controllers = append (controllers ,
0 commit comments