github.com/openshift/installer@v1.4.17/pkg/types/ibmcloud/platform.go (about) 1 package ibmcloud 2 3 import ( 4 configv1 "github.com/openshift/api/config/v1" 5 ) 6 7 const ( 8 // IBM Cloud Service Endpoint variables are supplied via documentation: 9 // https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/guides/custom-service-endpoints#supported-endpoint-customizations 10 11 // IBMCloudServiceCISVar is the variable name used by the IBM Cloud Terraform Provider to override the CIS endpoint. 12 IBMCloudServiceCISVar string = "IBMCLOUD_CIS_API_ENDPOINT" 13 14 // IBMCloudServiceCOSVar is the variable name used by the IBM Cloud Terraform Provider to override the COS endpoint. 15 IBMCloudServiceCOSVar string = "IBMCLOUD_COS_CONFIG_ENDPOINT" 16 17 // IBMCloudServiceDNSServicesVar is the variable name used by the IBM Cloud Terraform Provider to override the DNS Services endpoint. 18 IBMCloudServiceDNSServicesVar string = "IBMCLOUD_PRIVATE_DNS_API_ENDPOINT" 19 20 // IBMCloudServiceGlobalSearchVar is the variable name used by the IBM Cloud Terraform Provider to override the Global Search endpoint. 21 IBMCloudServiceGlobalSearchVar string = "IBMCLOUD_GS_API_ENDPOINT" //nolint:gosec // not hardcoded creds 22 23 // IBMCloudServiceGlobalTaggingVar is the variable name used by the IBM Cloud Terraform Provider to override the Global Tagging endpoint. 24 IBMCloudServiceGlobalTaggingVar string = "IBMCLOUD_GT_API_ENDPOINT" //nolint:gosec // not hardcoded creds 25 26 // IBMCloudServiceHyperProtectVar is the variable name used by the IBM Cloud Terraform Provider to override the Hyper Protect endpoint. 27 IBMCloudServiceHyperProtectVar string = "IBMCLOUD_HPCS_API_ENDPOINT" 28 29 // IBMCloudServiceIAMVar is the variable name used by the IBM Cloud Terraform Provider to override the IAM endpoint. 30 IBMCloudServiceIAMVar string = "IBMCLOUD_IAM_API_ENDPOINT" 31 32 // IBMCloudServiceKeyProtectVar is the variable name used by the IBM Cloud Terraform Provider to override the Key Protect endpoint. 33 IBMCloudServiceKeyProtectVar string = "IBMCLOUD_KP_API_ENDPOINT" //nolint:gosec // not hardcoded creds 34 35 // IBMCloudServiceResourceControllerVar is the variable name used by the IBM Cloud Terraform Provider to override the Resource Controller endpoint. 36 IBMCloudServiceResourceControllerVar string = "IBMCLOUD_RESOURCE_CONTROLLER_API_ENDPOINT" 37 38 // IBMCloudServiceResourceManagerVar is the variable name used by the IBM Cloud Terraform Provider to override the Resource Manager endpoint. 39 IBMCloudServiceResourceManagerVar string = "IBMCLOUD_RESOURCE_MANAGEMENT_API_ENDPOINT" 40 41 // IBMCloudServiceVPCVar is the variable name used by the IBM Cloud Terraform Provider to override the VPC endpoint. 42 IBMCloudServiceVPCVar string = "IBMCLOUD_IS_NG_API_ENDPOINT" 43 ) 44 45 var ( 46 // IBMCloudServiceOverrides is a set of IBM Cloud services allowed to have their endpoints overridden mapped to their override variable. 47 IBMCloudServiceOverrides = map[configv1.IBMCloudServiceName]string{ 48 configv1.IBMCloudServiceCIS: IBMCloudServiceCISVar, 49 configv1.IBMCloudServiceCOS: IBMCloudServiceCOSVar, 50 configv1.IBMCloudServiceDNSServices: IBMCloudServiceDNSServicesVar, 51 configv1.IBMCloudServiceGlobalSearch: IBMCloudServiceGlobalSearchVar, 52 configv1.IBMCloudServiceGlobalTagging: IBMCloudServiceGlobalTaggingVar, 53 configv1.IBMCloudServiceHyperProtect: IBMCloudServiceHyperProtectVar, 54 configv1.IBMCloudServiceIAM: IBMCloudServiceIAMVar, 55 configv1.IBMCloudServiceKeyProtect: IBMCloudServiceKeyProtectVar, 56 configv1.IBMCloudServiceResourceController: IBMCloudServiceResourceControllerVar, 57 configv1.IBMCloudServiceResourceManager: IBMCloudServiceResourceManagerVar, 58 configv1.IBMCloudServiceVPC: IBMCloudServiceVPCVar, 59 } 60 ) 61 62 // EndpointsJSON represents the JSON format to override IBM Cloud Terraform provider utilized service endpoints. 63 // https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/guides/custom-service-endpoints#file-structure-for-endpoints-file 64 type EndpointsJSON struct { 65 // IBMCloudEndpointCIS contains endpoint mapping for IBM Cloud CIS. 66 IBMCloudEndpointCIS *EndpointsVisibility `json:"IBMCLOUD_CIS_API_ENDPOINT,omitempty"` 67 68 // IBMCloudEndpointCOS contains endpoint mapping for IBM Cloud COS. 69 IBMCloudEndpointCOS *EndpointsVisibility `json:"IBMCLOUD_COS_CONFIG_ENDPOINT,omitempty"` 70 71 // IBMCloudEndpointDNSServices contains endpoint mapping for IBM Cloud DNS Services. 72 IBMCloudEndpointDNSServices *EndpointsVisibility `json:"IBMCLOUD_PRIVATE_DNS_API_ENDPOINT,omitempty"` 73 74 // IBMCloudEndpointGlobalSearch contains endpoint mapping for IBM Cloud Global Search. 75 IBMCloudEndpointGlobalSearch *EndpointsVisibility `json:"IBMCLOUD_GS_API_ENDPOINT,omitempty"` 76 77 // IBMCloudEndpointGlobalTagging contains endpoint mapping for IBM Cloud Global Tagging. 78 IBMCloudEndpointGlobalTagging *EndpointsVisibility `json:"IBMCLOUD_GT_API_ENDPOINT,omitempty"` 79 80 // IBMCloudEndpointHyperProtect contains endpoint mapping for IBM Cloud Hyper Protect. 81 IBMCloudEndpointHyperProtect *EndpointsVisibility `json:"IBMCLOUD_HPCS_API_ENDPOINT,omitempty"` 82 83 // IBMCloudEndpointIAM contains endpoint mapping for IBM Cloud IAM. 84 IBMCloudEndpointIAM *EndpointsVisibility `json:"IBMCLOUD_IAM_API_ENDPOINT,omitempty"` 85 86 // IBMCloudEndpointKeyProtect contains endpoint mapping for IBM Cloud Key Protect. 87 IBMCloudEndpointKeyProtect *EndpointsVisibility `json:"IBMCLOUD_KP_API_ENDPOINT,omitempty"` 88 89 // IBMCloudEndpointResourceController contains endpoint mapping for IBM Cloud Resource Controller. 90 IBMCloudEndpointResourceController *EndpointsVisibility `json:"IBMCLOUD_RESOURCE_CONTROLLER_API_ENDPOINT,omitempty"` 91 92 // IBMCloudEndpointResourceManager contains endpoint mapping for IBM Cloud Resource Manager. 93 IBMCloudEndpointResourceManager *EndpointsVisibility `json:"IBMCLOUD_RESOURCE_MANAGEMENT_API_ENDPOINT,omitempty"` 94 95 // IBMCloudEndpointVPC contains endpoint mapping for IBM Cloud VPC. 96 IBMCloudEndpointVPC *EndpointsVisibility `json:"IBMCLOUD_IS_NG_API_ENDPOINT,omitempty"` 97 } 98 99 // EndpointsVisibility contains region mapped endpoint for a service. 100 type EndpointsVisibility struct { 101 // Private is a string-string map of a region name to endpoint URL 102 // To prevent maintaining a list of supported regions here, we simply use a map instead of a struct 103 Private map[string]string `json:"private"` 104 105 // Public is a string-string map of a region name to endpoint URL 106 // To prevent maintaining a list of supported regions here, we simply use a map instead of a struct 107 Public map[string]string `json:"public"` 108 } 109 110 // CheckServiceEndpointOverride checks whether a service has an override endpoint. 111 func CheckServiceEndpointOverride(service configv1.IBMCloudServiceName, serviceEndpoints []configv1.IBMCloudServiceEndpoint) string { 112 if len(serviceEndpoints) > 0 { 113 for _, endpoint := range serviceEndpoints { 114 if endpoint.Name == service { 115 return endpoint.URL 116 } 117 } 118 } 119 return "" 120 } 121 122 // Platform stores all the global configuration that all machinesets use. 123 type Platform struct { 124 // Region specifies the IBM Cloud region where the cluster will be 125 // created. 126 Region string `json:"region"` 127 128 // ResourceGroupName is the name of an already existing resource group where the 129 // cluster should be installed. If empty, a new resource group will be created 130 // for the cluster. 131 // +optional 132 ResourceGroupName string `json:"resourceGroupName,omitempty"` 133 134 // NetworkResourceGroupName is the name of an already existing resource group 135 // where an existing VPC and set of Subnets exist, to be used during cluster 136 // creation. 137 // +optional 138 NetworkResourceGroupName string `json:"networkResourceGroupName,omitempty"` 139 140 // VPCName is the name of an already existing VPC to be used during cluster 141 // creation. 142 // +optional 143 VPCName string `json:"vpcName,omitempty"` 144 145 // ControlPlaneSubnets are the names of already existing subnets where the 146 // cluster control plane nodes should be created. 147 // +optional 148 ControlPlaneSubnets []string `json:"controlPlaneSubnets,omitempty"` 149 150 // ComputeSubnets are the names of already existing subnets where the cluster 151 // compute nodes should be created. 152 // +optional 153 ComputeSubnets []string `json:"computeSubnets,omitempty"` 154 155 // DefaultMachinePlatform is the default configuration used when installing 156 // on IBM Cloud for machine pools which do not define their own platform 157 // configuration. 158 // +optional 159 DefaultMachinePlatform *MachinePool `json:"defaultMachinePlatform,omitempty"` 160 161 // ServiceEndpoints is a list which contains custom endpoints to override default 162 // service endpoints of IBM Cloud Services. 163 // There must only be one ServiceEndpoint for a service (no duplicates). 164 // +optional 165 ServiceEndpoints []configv1.IBMCloudServiceEndpoint `json:"serviceEndpoints,omitempty"` 166 } 167 168 // ClusterResourceGroupName returns the name of the resource group for the cluster. 169 func (p *Platform) ClusterResourceGroupName(infraID string) string { 170 if len(p.ResourceGroupName) > 0 { 171 return p.ResourceGroupName 172 } 173 return infraID 174 } 175 176 // GetVPCName returns the user provided name of the VPC for the cluster. 177 func (p *Platform) GetVPCName() string { 178 if len(p.VPCName) > 0 { 179 return p.VPCName 180 } 181 return "" 182 }