mirror of https://github.com/hashicorp/terraform
parent
b256c77423
commit
91cb3e2833
@ -0,0 +1,43 @@
|
||||
package azure
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type Endpoints struct {
|
||||
resourceManagerEndpointUrl string
|
||||
activeDirectoryEndpointUrl string
|
||||
}
|
||||
|
||||
var (
|
||||
ChineseEndpoints = Endpoints{"https://management.chinacloudapi.cn", "https://login.chinacloudapi.cn"}
|
||||
DefaultEndpoints = Endpoints{"https://management.azure.com", "https://login.microsoftonline.com"}
|
||||
GermanEndpoints = Endpoints{"https://management.microsoftazure.de", "https://login.microsoftonline.de"}
|
||||
USGovEndpoints = Endpoints{"https://management.usgovcloudapi.net", "https://login.microsoftonline.com"}
|
||||
)
|
||||
|
||||
func GetEndpointsForLocation(location string) Endpoints {
|
||||
location = strings.Replace(strings.ToLower(location), " ", "", -1)
|
||||
|
||||
switch location {
|
||||
case GermanyCentral, GermanyEast:
|
||||
return GermanEndpoints
|
||||
case ChinaEast, ChinaNorth:
|
||||
return ChineseEndpoints
|
||||
case USGovIowa, USGovVirginia:
|
||||
return USGovEndpoints
|
||||
default:
|
||||
return DefaultEndpoints
|
||||
}
|
||||
}
|
||||
|
||||
func GetEndpointsForCommand(command APICall) Endpoints {
|
||||
locationField := reflect.Indirect(reflect.ValueOf(command)).FieldByName("Location")
|
||||
if locationField.IsValid() {
|
||||
location := locationField.Interface().(string)
|
||||
return GetEndpointsForLocation(location)
|
||||
}
|
||||
|
||||
return DefaultEndpoints
|
||||
}
|
||||
@ -1,26 +1,33 @@
|
||||
package azure
|
||||
|
||||
const (
|
||||
Global = "global"
|
||||
CentralUS = "centralus"
|
||||
EastUS = "eastus"
|
||||
EastUS2 = "eastus2"
|
||||
USGovIowa = "usgoviowa"
|
||||
USGovVirginia = "usgovvirginia"
|
||||
NorthCentralUS = "northcentralus"
|
||||
SouthCentralUS = "southcentralus"
|
||||
WestUS = "westus"
|
||||
NorthEurope = "northeurope"
|
||||
WestEurope = "westeurope"
|
||||
EastAsia = "eastasia"
|
||||
SoutheastAsia = "southeastasia"
|
||||
JapanEast = "japaneast"
|
||||
JapanWest = "japanwest"
|
||||
BrazilSouth = "brazilsouth"
|
||||
AustraliaEast = "australiaeast"
|
||||
Australia = "australia"
|
||||
CentralIndia = "centralindia"
|
||||
SouthIndia = "southindia"
|
||||
WestIndia = "westindia"
|
||||
ChinaEast = "chinaeast"
|
||||
Global = "global"
|
||||
CentralUS = "centralus"
|
||||
EastUS = "eastus"
|
||||
EastUS2 = "eastus2"
|
||||
USGovIowa = "usgoviowa"
|
||||
USGovVirginia = "usgovvirginia"
|
||||
NorthCentralUS = "northcentralus"
|
||||
SouthCentralUS = "southcentralus"
|
||||
WestUS = "westus"
|
||||
NorthEurope = "northeurope"
|
||||
WestEurope = "westeurope"
|
||||
EastAsia = "eastasia"
|
||||
SoutheastAsia = "southeastasia"
|
||||
JapanEast = "japaneast"
|
||||
JapanWest = "japanwest"
|
||||
BrazilSouth = "brazilsouth"
|
||||
AustraliaEast = "australiaeast"
|
||||
AustraliaSouthEast = "australiasoutheast"
|
||||
CentralIndia = "centralindia"
|
||||
SouthIndia = "southindia"
|
||||
WestIndia = "westindia"
|
||||
ChinaEast = "chinaeast"
|
||||
ChinaNorth = "chinanorth"
|
||||
UKSouth = "uksouth"
|
||||
UKWest = "ukwest"
|
||||
CanadaCentral = "canadacentral"
|
||||
CanadaEast = "canadaeast"
|
||||
GermanyCentral = "germanycentral"
|
||||
GermanyEast = "germanyeast"
|
||||
)
|
||||
|
||||
Loading…
Reference in new issue