Skip to content

Commit 2596e5d

Browse files
Merge pull request openshift#7656 from patrickdillon/altinfra-image-tags
CORS-2835: use build tags to produce installer with alternate infrastructure providers
2 parents 53ce73d + 7014647 commit 2596e5d

File tree

6 files changed

+63
-21
lines changed

6 files changed

+63
-21
lines changed

cmd/openshift-install/gather.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,10 @@ func runGatherBootstrapCmd(directory string) (string, error) {
122122
return "", errors.Wrapf(err, "failed to fetch %s", config.Name())
123123
}
124124

125-
provider := infra.ProviderForPlatform(config.Config.Platform.Name())
125+
provider, err := infra.ProviderForPlatform(config.Config.Platform.Name())
126+
if err != nil {
127+
return "", fmt.Errorf("error getting infrastructure provider: %w", err)
128+
}
126129
if err = provider.ExtractHostAddresses(directory, config.Config, ha); err != nil {
127130
logrus.Warnf("Failed to extract host addresses: %s", err.Error())
128131
}

hack/build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export CGO_ENABLED=0
4242
MODE="${MODE:-release}"
4343

4444
# Build terraform binaries before setting environment variables since it messes up make
45-
if test "${SKIP_TERRAFORM}" != y
45+
if test "${SKIP_TERRAFORM}" != y && ! (echo "${TAGS}" | grep -q -e 'aro' -e 'altinfra')
4646
then
4747
make -j8 -C terraform all
4848
copy_terraform_to_mirror # Copy terraform parts to embedded mirror.

pkg/asset/cluster/cluster.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,10 @@ func (c *Cluster) Generate(parents asset.Parents) (err error) {
109109
tfvarsFiles = append(tfvarsFiles, file)
110110
}
111111

112-
provider := infra.ProviderForPlatform(platform)
112+
provider, err := infra.ProviderForPlatform(platform)
113+
if err != nil {
114+
return fmt.Errorf("error getting infrastructure provider: %w", err)
115+
}
113116
files, err := provider.Provision(InstallDir, tfvarsFiles)
114117
c.FileList = append(c.FileList, files...) // append state files even in case of failure
115118
if err != nil {

pkg/destroy/bootstrap/bootstrap.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,11 @@ func Destroy(dir string) (err error) {
4242
platform = typesazure.StackTerraformName
4343
}
4444

45-
provider := infra.ProviderForPlatform(platform)
45+
provider, err := infra.ProviderForPlatform(platform)
46+
if err != nil {
47+
return fmt.Errorf("error getting infrastructure provider: %w", err)
48+
}
49+
4650
if err := provider.DestroyBootstrap(dir); err != nil {
4751
return fmt.Errorf("error destroying bootstrap resources %w", err)
4852
}

pkg/infrastructure/platform/platform.go

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
//go:build !(altinfra || aro)
2+
// +build !altinfra,!aro
3+
14
package platform
25

36
import (
@@ -34,40 +37,40 @@ import (
3437
)
3538

3639
// ProviderForPlatform returns the stages to run to provision the infrastructure for the specified platform.
37-
func ProviderForPlatform(platform string) infrastructure.Provider {
40+
func ProviderForPlatform(platform string) (infrastructure.Provider, error) {
3841
switch platform {
3942
case alibabacloudtypes.Name:
40-
return terraform.InitializeProvider(alibabacloud.PlatformStages)
43+
return terraform.InitializeProvider(alibabacloud.PlatformStages), nil
4144
case awstypes.Name:
42-
return terraform.InitializeProvider(aws.PlatformStages)
45+
return terraform.InitializeProvider(aws.PlatformStages), nil
4346
case azuretypes.Name:
44-
return terraform.InitializeProvider(azure.PlatformStages)
47+
return terraform.InitializeProvider(azure.PlatformStages), nil
4548
case azuretypes.StackTerraformName:
46-
return terraform.InitializeProvider(azure.StackPlatformStages)
49+
return terraform.InitializeProvider(azure.StackPlatformStages), nil
4750
case baremetaltypes.Name:
48-
return terraform.InitializeProvider(baremetal.PlatformStages)
51+
return terraform.InitializeProvider(baremetal.PlatformStages), nil
4952
case gcptypes.Name:
50-
return terraform.InitializeProvider(gcp.PlatformStages)
53+
return terraform.InitializeProvider(gcp.PlatformStages), nil
5154
case ibmcloudtypes.Name:
52-
return terraform.InitializeProvider(ibmcloud.PlatformStages)
55+
return terraform.InitializeProvider(ibmcloud.PlatformStages), nil
5356
case libvirttypes.Name:
54-
return terraform.InitializeProvider(libvirt.PlatformStages)
57+
return terraform.InitializeProvider(libvirt.PlatformStages), nil
5558
case nutanixtypes.Name:
56-
return terraform.InitializeProvider(nutanix.PlatformStages)
59+
return terraform.InitializeProvider(nutanix.PlatformStages), nil
5760
case powervstypes.Name:
58-
return terraform.InitializeProvider(powervs.PlatformStages)
61+
return terraform.InitializeProvider(powervs.PlatformStages), nil
5962
case openstacktypes.Name:
60-
return terraform.InitializeProvider(openstack.PlatformStages)
63+
return terraform.InitializeProvider(openstack.PlatformStages), nil
6164
case ovirttypes.Name:
62-
return terraform.InitializeProvider(ovirt.PlatformStages)
65+
return terraform.InitializeProvider(ovirt.PlatformStages), nil
6366
case vspheretypes.Name:
64-
return terraform.InitializeProvider(vsphere.PlatformStages)
67+
return terraform.InitializeProvider(vsphere.PlatformStages), nil
6568
case nonetypes.Name:
6669
// terraform is not used when the platform is "none"
67-
return terraform.InitializeProvider([]terraform.Stage{})
70+
return terraform.InitializeProvider([]terraform.Stage{}), nil
6871
case externaltypes.Name:
6972
// terraform is not used when the platform is "external"
70-
return terraform.InitializeProvider([]terraform.Stage{})
73+
return terraform.InitializeProvider([]terraform.Stage{}), nil
7174
}
72-
panic(fmt.Sprintf("unsupported platform %q", platform))
75+
return nil, fmt.Errorf("unsupported platform %q", platform)
7376
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
//go:build altinfra || aro
2+
// +build altinfra aro
3+
4+
package platform
5+
6+
import (
7+
"fmt"
8+
9+
"github.com/openshift/installer/pkg/infrastructure"
10+
awstypes "github.com/openshift/installer/pkg/types/aws"
11+
azuretypes "github.com/openshift/installer/pkg/types/azure"
12+
vspheretypes "github.com/openshift/installer/pkg/types/vsphere"
13+
)
14+
15+
// ProviderForPlatform returns the stages to run to provision the infrastructure for the specified platform.
16+
func ProviderForPlatform(platform string) (infrastructure.Provider, error) {
17+
switch platform {
18+
case awstypes.Name:
19+
panic("not implemented")
20+
return nil, nil
21+
case azuretypes.Name:
22+
panic("not implemented")
23+
return nil, nil
24+
case vspheretypes.Name:
25+
panic("not implemented")
26+
return nil, nil
27+
}
28+
return nil, fmt.Errorf("platform %q is not supported in the altinfra Installer build", platform)
29+
}

0 commit comments

Comments
 (0)