From 97b1915d51668b4d4d0167fc244126a3848aa395 Mon Sep 17 00:00:00 2001 From: Christopher Boumenot Date: Wed, 20 Jul 2016 12:09:41 -0700 Subject: [PATCH] Update Azure dependencies * azure-sdk-for-go to 3.1.0-beta * go-autorest to 7.0.7 * import dgrijalva/jwt-go at 3.0.0 --- builder/azure/arm/config.go | 38 +++++++++++++++------- builder/azure/common/vault_test.go | 1 - website/source/docs/builders/azure.html.md | 2 +- 3 files changed, 28 insertions(+), 13 deletions(-) diff --git a/builder/azure/arm/config.go b/builder/azure/arm/config.go index cf3a731d0..355ee8e47 100644 --- a/builder/azure/arm/config.go +++ b/builder/azure/arm/config.go @@ -299,21 +299,37 @@ func setUserNamePassword(c *Config) { } func setCloudEnvironment(c *Config) error { + lookup := map[string]string{ + "CHINA": "AzureChinaCloud", + "CHINACLOUD": "AzureChinaCloud", + "AZURECHINACLOUD": "AzureChinaCloud", + + "GERMAN": "AzureGermanCloud", + "GERMANCLOUD": "AzureGermanCloud", + "AZUREGERMANCLOUD": "AzureGermanCloud", + + "GERMANY": "AzureGermanCloud", + "GERMANYCLOUD": "AzureGermanCloud", + "AZUREGERMANYCLOUD": "AzureGermanCloud", + + "PUBLIC": "AzurePublicCloud", + "PUBLICCLOUD": "AzurePublicCloud", + "AZUREPUBLICCLOUD": "AzurePublicCloud", + + "USGOVERNMENT": "AzureUSGovernmentCloud", + "USGOVERNMENTCLOUD": "AzureUSGovernmentCloud", + "AZUREUSGOVERNMENTCLOUD": "AzureUSGovernmentCloud", + } + name := strings.ToUpper(c.CloudEnvironmentName) - switch name { - case "CHINA", "CHINACLOUD", "AZURECHINACLOUD": - c.cloudEnvironment = &azure.ChinaCloud - case "GERMAN", "GERMANCLOUD", "AZUREGERMANCLOUD": - c.cloudEnvironment = &azure.GermanCloud - case "PUBLIC", "PUBLICCLOUD", "AZUREPUBLICCLOUD": - c.cloudEnvironment = &azure.PublicCloud - case "USGOVERNMENT", "USGOVERNMENTCLOUD", "AZUREUSGOVERNMENTCLOUD": - c.cloudEnvironment = &azure.USGovernmentCloud - default: + envName, ok := lookup[name] + if !ok { return fmt.Errorf("There is no cloud envionment matching the name '%s'!", c.CloudEnvironmentName) } - return nil + env, err := azure.EnvironmentFromName(envName) + c.cloudEnvironment = &env + return err } func provideDefaultValues(c *Config) { diff --git a/builder/azure/common/vault_test.go b/builder/azure/common/vault_test.go index cf7dc65cd..d1c94d76c 100644 --- a/builder/azure/common/vault_test.go +++ b/builder/azure/common/vault_test.go @@ -24,4 +24,3 @@ func TestVaultClientKeyVaultEndpointPreserveScheme(t *testing.T) { t.Errorf("expected \"http://my.vault.azure.net/\", got %q", vaultUrl) } } - diff --git a/website/source/docs/builders/azure.html.md b/website/source/docs/builders/azure.html.md index c09768848..adc5655b8 100644 --- a/website/source/docs/builders/azure.html.md +++ b/website/source/docs/builders/azure.html.md @@ -57,7 +57,7 @@ builder. ### Optional: -- `cloud_environment_name` (string) One of `Public`, `China`, `German`, or +- `cloud_environment_name` (string) One of `Public`, `China`, `Germany`, or `USGovernment`. Defaults to `Public`. Long forms such as `USGovernmentCloud` and `AzureUSGovernmentCloud` are also supported.