Skip to content

Instantly share code, notes, and snippets.

@hamzy
Created March 19, 2024 19:26
Show Gist options
  • Save hamzy/7ff1905012077b2bfbfb2952eae0de52 to your computer and use it in GitHub Desktop.
Save hamzy/7ff1905012077b2bfbfb2952eae0de52 to your computer and use it in GitHub Desktop.
20240319 ./pkg/infrastructure/platform/platform_altinfra.go
//go:build altinfra
// +build altinfra
package platform
import (
"fmt"
configv1 "github.com/openshift/api/config/v1"
"github.com/openshift/installer/pkg/infrastructure"
"github.com/openshift/installer/pkg/infrastructure/aws"
awscapi "github.com/openshift/installer/pkg/infrastructure/aws/clusterapi"
azurecapi "github.com/openshift/installer/pkg/infrastructure/azure"
"github.com/openshift/installer/pkg/infrastructure/clusterapi"
gcpcapi "github.com/openshift/installer/pkg/infrastructure/gcp/clusterapi"
ibmcloudcapi "github.com/openshift/installer/pkg/infrastructure/ibmcloud/clusterapi"
openstackcapi "github.com/openshift/installer/pkg/infrastructure/openstack/clusterapi"
powervscapi "github.com/openshift/installer/pkg/infrastructure/powervs/clusterapi"
vspherecapi "github.com/openshift/installer/pkg/infrastructure/vsphere/clusterapi"
awstypes "github.com/openshift/installer/pkg/types/aws"
azuretypes "github.com/openshift/installer/pkg/types/azure"
"github.com/openshift/installer/pkg/types/featuregates"
gcptypes "github.com/openshift/installer/pkg/types/gcp"
ibmcloudtypes "github.com/openshift/installer/pkg/types/ibmcloud"
openstacktypes "github.com/openshift/installer/pkg/types/openstack"
powervstypes "github.com/openshift/installer/pkg/types/powervs"
vspheretypes "github.com/openshift/installer/pkg/types/vsphere"
)
// ProviderForPlatform returns the stages to run to provision the infrastructure for the specified platform.
func ProviderForPlatform(platform string, fg featuregates.FeatureGate) (infrastructure.Provider, error) {
switch platform {
case awstypes.Name:
if fg.Enabled(configv1.FeatureGateClusterAPIInstall) {
return clusterapi.InitializeProvider(&awscapi.Provider{}), nil
}
return aws.InitializeProvider(), nil
case azuretypes.Name:
if fg.Enabled(configv1.FeatureGateClusterAPIInstall) {
return clusterapi.InitializeProvider(&azurecapi.Provider{}), nil
}
return nil, nil
case gcptypes.Name:
if fg.Enabled(configv1.FeatureGateClusterAPIInstall) {
return clusterapi.InitializeProvider(gcpcapi.Provider{}), nil
}
return nil, nil
case ibmcloudtypes.Name:
if fg.Enabled(configv1.FeatureGateClusterAPIInstall) {
return clusterapi.InitializeProvider(ibmcloudcapi.Provider{}), nil
}
return nil, nil
case vspheretypes.Name:
if fg.Enabled(configv1.FeatureGateClusterAPIInstall) {
return clusterapi.InitializeProvider(vspherecapi.Provider{}), nil
}
case powervstypes.Name:
if fg.Enabled(configv1.FeatureGateClusterAPIInstall) {
return clusterapi.InitializeProvider(powervscapi.Provider{}), nil
}
return nil, nil
case openstacktypes.Name:
if fg.Enabled(configv1.FeatureGateClusterAPIInstall) {
return clusterapi.InitializeProvider(openstackcapi.Provider{}), nil
}
}
return nil, fmt.Errorf("platform %q is not supported in the altinfra Installer build", platform)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment