Skip to content

Commit a621ac9

Browse files
stephenfinpierreprinetti
authored andcommitted
cluster-api: Use constants for existing platforms
We also fix a typo in an error log. Signed-off-by: Stephen Finucane <[email protected]>
1 parent 4e10cd5 commit a621ac9

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

pkg/asset/machines/clusterapi.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ import (
1919
"github.com/openshift/installer/pkg/asset/machines/aws"
2020
"github.com/openshift/installer/pkg/asset/manifests/capiutils"
2121
"github.com/openshift/installer/pkg/asset/rhcos"
22+
awstypes "github.com/openshift/installer/pkg/types/aws"
2223
awsdefaults "github.com/openshift/installer/pkg/types/aws/defaults"
24+
azuretypes "github.com/openshift/installer/pkg/types/azure"
2325
)
2426

2527
// GenerateClusterAPI generates manifests for target cluster.
@@ -30,7 +32,7 @@ func GenerateClusterAPI(ctx context.Context, installConfig *installconfig.Instal
3032
pool := *ic.ControlPlane
3133

3234
switch ic.Platform.Name() {
33-
case "aws":
35+
case awstypes.Name:
3436
subnets := map[string]string{}
3537
if len(ic.Platform.AWS.Subnets) > 0 {
3638
subnetMeta, err := installConfig.AWS.PrivateSubnets(ctx)
@@ -169,7 +171,8 @@ func GenerateClusterAPI(ctx context.Context, installConfig *installconfig.Instal
169171
File: asset.File{Filename: fmt.Sprintf("10_machine_%s.yaml", bootstrapMachine.Name)},
170172
Object: bootstrapMachine,
171173
})
172-
case "azure":
174+
case azuretypes.Name:
175+
// TODO: implement
173176
default:
174177
// TODO: support other platforms
175178
}

pkg/asset/manifests/clusterapi/cluster.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ import (
2626
"github.com/openshift/installer/pkg/asset/openshiftinstall"
2727
"github.com/openshift/installer/pkg/asset/rhcos"
2828
"github.com/openshift/installer/pkg/clusterapi"
29+
awstypes "github.com/openshift/installer/pkg/types/aws"
30+
azuretypes "github.com/openshift/installer/pkg/types/azure"
2931
)
3032

3133
const (
@@ -142,7 +144,7 @@ func (c *Cluster) Generate(dependencies asset.Parents) error {
142144

143145
var out *capiutils.GenerateClusterAssetsOutput
144146
switch platform := installConfig.Config.Platform.Name(); platform {
145-
case "aws":
147+
case awstypes.Name:
146148
// Move this somewhere else.
147149
// if err := aws.PutIAMRoles(clusterID.InfraID, installConfig); err != nil {
148150
// return errors.Wrap(err, "failed to create IAM roles")
@@ -152,11 +154,11 @@ func (c *Cluster) Generate(dependencies asset.Parents) error {
152154
if err != nil {
153155
return errors.Wrap(err, "failed to generate AWS manifests")
154156
}
155-
case "azure":
157+
case azuretypes.Name:
156158
var err error
157159
out, err = azure.GenerateClusterAssets(installConfig, clusterID)
158160
if err != nil {
159-
return errors.Wrap(err, "failed to generate AWS manifests")
161+
return errors.Wrap(err, "failed to generate Azure manifests")
160162
}
161163
default:
162164
return fmt.Errorf("unsupported platform %q", platform)

0 commit comments

Comments
 (0)