github.com/openshift/installer@v1.4.17/pkg/infrastructure/platform/platform.go (about)

     1  //go:build !altinfra
     2  // +build !altinfra
     3  
     4  package platform
     5  
     6  import (
     7  	"fmt"
     8  
     9  	"github.com/openshift/installer/pkg/infrastructure"
    10  	awscapi "github.com/openshift/installer/pkg/infrastructure/aws/clusterapi"
    11  	azureinfra "github.com/openshift/installer/pkg/infrastructure/azure"
    12  	baremetalinfra "github.com/openshift/installer/pkg/infrastructure/baremetal"
    13  	"github.com/openshift/installer/pkg/infrastructure/clusterapi"
    14  	gcpcapi "github.com/openshift/installer/pkg/infrastructure/gcp/clusterapi"
    15  	ibmcloudcapi "github.com/openshift/installer/pkg/infrastructure/ibmcloud/clusterapi"
    16  	nutanixcapi "github.com/openshift/installer/pkg/infrastructure/nutanix/clusterapi"
    17  	openstackcapi "github.com/openshift/installer/pkg/infrastructure/openstack/clusterapi"
    18  	powervscapi "github.com/openshift/installer/pkg/infrastructure/powervs/clusterapi"
    19  	vspherecapi "github.com/openshift/installer/pkg/infrastructure/vsphere/clusterapi"
    20  	"github.com/openshift/installer/pkg/terraform"
    21  	"github.com/openshift/installer/pkg/terraform/stages/azure"
    22  	"github.com/openshift/installer/pkg/terraform/stages/ibmcloud"
    23  	"github.com/openshift/installer/pkg/terraform/stages/ovirt"
    24  	"github.com/openshift/installer/pkg/types"
    25  	awstypes "github.com/openshift/installer/pkg/types/aws"
    26  	azuretypes "github.com/openshift/installer/pkg/types/azure"
    27  	baremetaltypes "github.com/openshift/installer/pkg/types/baremetal"
    28  	externaltypes "github.com/openshift/installer/pkg/types/external"
    29  	"github.com/openshift/installer/pkg/types/featuregates"
    30  	gcptypes "github.com/openshift/installer/pkg/types/gcp"
    31  	ibmcloudtypes "github.com/openshift/installer/pkg/types/ibmcloud"
    32  	nonetypes "github.com/openshift/installer/pkg/types/none"
    33  	nutanixtypes "github.com/openshift/installer/pkg/types/nutanix"
    34  	openstacktypes "github.com/openshift/installer/pkg/types/openstack"
    35  	ovirttypes "github.com/openshift/installer/pkg/types/ovirt"
    36  	powervstypes "github.com/openshift/installer/pkg/types/powervs"
    37  	vspheretypes "github.com/openshift/installer/pkg/types/vsphere"
    38  )
    39  
    40  // ProviderForPlatform returns the stages to run to provision the infrastructure for the specified platform.
    41  func ProviderForPlatform(platform string, fg featuregates.FeatureGate) (infrastructure.Provider, error) {
    42  	switch platform {
    43  	case awstypes.Name:
    44  		return clusterapi.InitializeProvider(&awscapi.Provider{}), nil
    45  	case azuretypes.Name:
    46  		return clusterapi.InitializeProvider(&azureinfra.Provider{}), nil
    47  	case azuretypes.StackTerraformName:
    48  		return terraform.InitializeProvider(azure.StackPlatformStages), nil
    49  	case baremetaltypes.Name:
    50  		return baremetalinfra.InitializeProvider(), nil
    51  	case gcptypes.Name:
    52  		return clusterapi.InitializeProvider(gcpcapi.Provider{}), nil
    53  	case ibmcloudtypes.Name:
    54  		if types.ClusterAPIFeatureGateEnabled(platform, fg) {
    55  			return clusterapi.InitializeProvider(ibmcloudcapi.Provider{}), nil
    56  		}
    57  		return terraform.InitializeProvider(ibmcloud.PlatformStages), nil
    58  	case nutanixtypes.Name:
    59  		return clusterapi.InitializeProvider(nutanixcapi.Provider{}), nil
    60  	case powervstypes.Name:
    61  		return clusterapi.InitializeProvider(&powervscapi.Provider{}), nil
    62  	case openstacktypes.Name:
    63  		return clusterapi.InitializeProvider(openstackcapi.Provider{}), nil
    64  	case ovirttypes.Name:
    65  		return terraform.InitializeProvider(ovirt.PlatformStages), nil
    66  	case vspheretypes.Name:
    67  		return clusterapi.InitializeProvider(vspherecapi.Provider{}), nil
    68  	case nonetypes.Name:
    69  		// terraform is not used when the platform is "none"
    70  		return terraform.InitializeProvider([]terraform.Stage{}), nil
    71  	case externaltypes.Name:
    72  		// terraform is not used when the platform is "external"
    73  		return terraform.InitializeProvider([]terraform.Stage{}), nil
    74  	}
    75  	return nil, fmt.Errorf("unsupported platform %q", platform)
    76  }