provider/azurerm: use configured environment for storage clients (#11159)
This fixes storage related operations for all environments outside of the public Azure cloud, tested by deploying all storage resources in a German subscription.
This commit is contained in:
parent
061925f190
commit
d97f7e5d7b
|
@ -32,6 +32,7 @@ type ArmClient struct {
|
||||||
clientId string
|
clientId string
|
||||||
tenantId string
|
tenantId string
|
||||||
subscriptionId string
|
subscriptionId string
|
||||||
|
environment azure.Environment
|
||||||
|
|
||||||
StopContext context.Context
|
StopContext context.Context
|
||||||
|
|
||||||
|
@ -131,13 +132,6 @@ func setUserAgent(client *autorest.Client) {
|
||||||
// getArmClient is a helper method which returns a fully instantiated
|
// getArmClient is a helper method which returns a fully instantiated
|
||||||
// *ArmClient based on the Config's current settings.
|
// *ArmClient based on the Config's current settings.
|
||||||
func (c *Config) getArmClient() (*ArmClient, error) {
|
func (c *Config) getArmClient() (*ArmClient, error) {
|
||||||
// client declarations:
|
|
||||||
client := ArmClient{
|
|
||||||
clientId: c.ClientID,
|
|
||||||
tenantId: c.TenantID,
|
|
||||||
subscriptionId: c.SubscriptionID,
|
|
||||||
}
|
|
||||||
|
|
||||||
// detect cloud from environment
|
// detect cloud from environment
|
||||||
env, envErr := azure.EnvironmentFromName(c.Environment)
|
env, envErr := azure.EnvironmentFromName(c.Environment)
|
||||||
if envErr != nil {
|
if envErr != nil {
|
||||||
|
@ -149,6 +143,14 @@ func (c *Config) getArmClient() (*ArmClient, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// client declarations:
|
||||||
|
client := ArmClient{
|
||||||
|
clientId: c.ClientID,
|
||||||
|
tenantId: c.TenantID,
|
||||||
|
subscriptionId: c.SubscriptionID,
|
||||||
|
environment: env,
|
||||||
|
}
|
||||||
|
|
||||||
rivieraClient, err := riviera.NewClient(&riviera.AzureResourceManagerCredentials{
|
rivieraClient, err := riviera.NewClient(&riviera.AzureResourceManagerCredentials{
|
||||||
ClientID: c.ClientID,
|
ClientID: c.ClientID,
|
||||||
ClientSecret: c.ClientSecret,
|
ClientSecret: c.ClientSecret,
|
||||||
|
@ -470,7 +472,8 @@ func (armClient *ArmClient) getBlobStorageClientForStorageAccount(resourceGroupN
|
||||||
return nil, false, nil
|
return nil, false, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
storageClient, err := mainStorage.NewBasicClient(storageAccountName, key)
|
storageClient, err := mainStorage.NewClient(storageAccountName, key, armClient.environment.StorageEndpointSuffix,
|
||||||
|
mainStorage.DefaultAPIVersion, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, true, fmt.Errorf("Error creating storage client for storage account %q: %s", storageAccountName, err)
|
return nil, true, fmt.Errorf("Error creating storage client for storage account %q: %s", storageAccountName, err)
|
||||||
}
|
}
|
||||||
|
@ -488,7 +491,8 @@ func (armClient *ArmClient) getFileServiceClientForStorageAccount(resourceGroupN
|
||||||
return nil, false, nil
|
return nil, false, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
storageClient, err := mainStorage.NewBasicClient(storageAccountName, key)
|
storageClient, err := mainStorage.NewClient(storageAccountName, key, armClient.environment.StorageEndpointSuffix,
|
||||||
|
mainStorage.DefaultAPIVersion, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, true, fmt.Errorf("Error creating storage client for storage account %q: %s", storageAccountName, err)
|
return nil, true, fmt.Errorf("Error creating storage client for storage account %q: %s", storageAccountName, err)
|
||||||
}
|
}
|
||||||
|
@ -506,7 +510,8 @@ func (armClient *ArmClient) getTableServiceClientForStorageAccount(resourceGroup
|
||||||
return nil, false, nil
|
return nil, false, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
storageClient, err := mainStorage.NewBasicClient(storageAccountName, key)
|
storageClient, err := mainStorage.NewClient(storageAccountName, key, armClient.environment.StorageEndpointSuffix,
|
||||||
|
mainStorage.DefaultAPIVersion, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, true, fmt.Errorf("Error creating storage client for storage account %q: %s", storageAccountName, err)
|
return nil, true, fmt.Errorf("Error creating storage client for storage account %q: %s", storageAccountName, err)
|
||||||
}
|
}
|
||||||
|
@ -524,7 +529,8 @@ func (armClient *ArmClient) getQueueServiceClientForStorageAccount(resourceGroup
|
||||||
return nil, false, nil
|
return nil, false, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
storageClient, err := mainStorage.NewBasicClient(storageAccountName, key)
|
storageClient, err := mainStorage.NewClient(storageAccountName, key, armClient.environment.StorageEndpointSuffix,
|
||||||
|
mainStorage.DefaultAPIVersion, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, true, fmt.Errorf("Error creating storage client for storage account %q: %s", storageAccountName, err)
|
return nil, true, fmt.Errorf("Error creating storage client for storage account %q: %s", storageAccountName, err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue