Skip to content

Commit

Permalink
provider/azurerm: Bump azure-sdk-for-go to 3.0.0-beta
Browse files Browse the repository at this point in the history
There were breaking changes to CDN Endpoint, CDN Profile and Storage
Account

The test results of the changes are as follows:

```
make testacc TEST=./builtin/providers/azurerm TESTARGS='-run=TestAccAzureRMCdnProfile'
==> Checking that code complies with gofmt requirements...
go generate $(go list ./... | grep -v /vendor/)
TF_ACC=1 go test ./builtin/providers/azurerm -v
-run=TestAccAzureRMCdnProfile -timeout 120m
=== RUN   TestAccAzureRMCdnProfile_basic
--- PASS: TestAccAzureRMCdnProfile_basic (199.61s)
=== RUN   TestAccAzureRMCdnProfile_withTags
--- PASS: TestAccAzureRMCdnProfile_withTags (214.24s)
PASS
ok      github.com/hashicorp/terraform/builtin/providers/azurerm
413.855s
```

```
make testacc TEST=./builtin/providers/azurerm TESTARGS='-run=TestAccAzureRMCdnEndpoint'
==> Checking that code complies with gofmt requirements...
go generate $(go list ./... | grep -v /vendor/)
TF_ACC=1 go test ./builtin/providers/azurerm -v
-run=TestAccAzureRMCdnEndpoint -timeout 120m
=== RUN   TestAccAzureRMCdnEndpoint_basic
--- PASS: TestAccAzureRMCdnEndpoint_basic (226.85s)
=== RUN   TestAccAzureRMCdnEndpoint_withTags
--- PASS: TestAccAzureRMCdnEndpoint_withTags (269.52s)
PASS
ok      github.com/hashicorp/terraform/builtin/providers/azurerm
496.382s
```

```
make testacc TEST=./builtin/providers/azurerm TESTARGS='-run=TestAccAzureRMStorageAccount_'
==> Checking that code complies with gofmt requirements...
go generate $(go list ./... | grep -v /vendor/)
TF_ACC=1 go test ./builtin/providers/azurerm -v
-run=TestAccAzureRMStorageAccount_ -timeout 120m
=== RUN   TestAccAzureRMStorageAccount_basic
--- PASS: TestAccAzureRMStorageAccount_basic (163.61s)
PASS
ok      github.com/hashicorp/terraform/builtin/providers/azurerm
163.621s
```
  • Loading branch information
stack72 committed Jun 30, 2016
1 parent d2df76e commit b9c7ae8
Show file tree
Hide file tree
Showing 101 changed files with 3,870 additions and 4,525 deletions.
9 changes: 5 additions & 4 deletions builtin/providers/azurerm/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,8 @@ func (c *Config) getArmClient() (*ArmClient, error) {
}

func (armClient *ArmClient) getKeyForStorageAccount(resourceGroupName, storageAccountName string) (string, bool, error) {
keys, err := armClient.storageServiceClient.ListKeys(resourceGroupName, storageAccountName)
if keys.StatusCode == http.StatusNotFound {
accountKeys, err := armClient.storageServiceClient.ListKeys(resourceGroupName, storageAccountName)
if accountKeys.StatusCode == http.StatusNotFound {
return "", false, nil
}
if err != nil {
Expand All @@ -331,11 +331,12 @@ func (armClient *ArmClient) getKeyForStorageAccount(resourceGroupName, storageAc
return "", true, fmt.Errorf("Error retrieving keys for storage account %q: %s", storageAccountName, err)
}

if keys.Key1 == nil {
if accountKeys.Keys == nil {
return "", false, fmt.Errorf("Nil key returned for storage account %q", storageAccountName)
}

return *keys.Key1, true, nil
keys := *accountKeys.Keys
return *keys[0].Value, true, nil
}

func (armClient *ArmClient) getBlobStorageClientForStorageAccount(resourceGroupName, storageAccountName string) (*mainStorage.BlobStorageClient, bool, error) {
Expand Down
17 changes: 4 additions & 13 deletions builtin/providers/azurerm/resource_arm_cdn_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ func resourceArmCdnEndpoint() *schema.Resource {
"origin": {
Type: schema.TypeSet,
Required: true,
ForceNew: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"name": {
Expand Down Expand Up @@ -149,7 +150,7 @@ func resourceArmCdnEndpointCreate(d *schema.ResourceData, meta interface{}) erro
caching_behaviour := d.Get("querystring_caching_behaviour").(string)
tags := d.Get("tags").(map[string]interface{})

properties := cdn.EndpointPropertiesCreateUpdateParameters{
properties := cdn.EndpointPropertiesCreateParameters{
IsHTTPAllowed: &http_allowed,
IsHTTPSAllowed: &https_allowed,
IsCompressionEnabled: &compression_enabled,
Expand Down Expand Up @@ -270,23 +271,13 @@ func resourceArmCdnEndpointUpdate(d *schema.ResourceData, meta interface{}) erro
caching_behaviour := d.Get("querystring_caching_behaviour").(string)
newTags := d.Get("tags").(map[string]interface{})

properties := cdn.EndpointPropertiesCreateUpdateParameters{
properties := cdn.EndpointPropertiesUpdateParameters{
IsHTTPAllowed: &http_allowed,
IsHTTPSAllowed: &https_allowed,
IsCompressionEnabled: &compression_enabled,
QueryStringCachingBehavior: cdn.QueryStringCachingBehavior(caching_behaviour),
}

if d.HasChange("origin") {
origins, originsErr := expandAzureRmCdnEndpointOrigins(d)
if originsErr != nil {
return fmt.Errorf("Error Building list of CDN Endpoint Origins: %s", originsErr)
}
if len(origins) > 0 {
properties.Origins = &origins
}
}

if d.HasChange("origin_host_header") {
host_header := d.Get("origin_host_header").(string)
properties.OriginHostHeader = &host_header
Expand All @@ -313,7 +304,7 @@ func resourceArmCdnEndpointUpdate(d *schema.ResourceData, meta interface{}) erro
Properties: &properties,
}

_, err := cdnEndpointsClient.Update(name, updateProps, profileName, resGroup)
_, err := cdnEndpointsClient.Update(name, updateProps, profileName, resGroup, make(chan struct{}))
if err != nil {
return fmt.Errorf("Error issuing Azure ARM update request to update CDN Endpoint %q: %s", name, err)
}
Expand Down
6 changes: 3 additions & 3 deletions builtin/providers/azurerm/resource_arm_cdn_endpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ resource "azurerm_cdn_profile" "test" {
name = "acctestcdnprof%d"
location = "West US"
resource_group_name = "${azurerm_resource_group.test.name}"
sku = "Standard"
sku = "Standard_Verizon"
}
resource "azurerm_cdn_endpoint" "test" {
Expand All @@ -158,7 +158,7 @@ resource "azurerm_cdn_profile" "test" {
name = "acctestcdnprof%d"
location = "West US"
resource_group_name = "${azurerm_resource_group.test.name}"
sku = "Standard"
sku = "Standard_Verizon"
}
resource "azurerm_cdn_endpoint" "test" {
Expand Down Expand Up @@ -190,7 +190,7 @@ resource "azurerm_cdn_profile" "test" {
name = "acctestcdnprof%d"
location = "West US"
resource_group_name = "${azurerm_resource_group.test.name}"
sku = "Standard"
sku = "Standard_Verizon"
}
resource "azurerm_cdn_endpoint" "test" {
Expand Down
24 changes: 11 additions & 13 deletions builtin/providers/azurerm/resource_arm_cdn_profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"log"
"net/http"

"strings"

"github.com/Azure/azure-sdk-for-go/arm/cdn"
Expand Down Expand Up @@ -61,18 +62,14 @@ func resourceArmCdnProfileCreate(d *schema.ResourceData, meta interface{}) error
sku := d.Get("sku").(string)
tags := d.Get("tags").(map[string]interface{})

properties := cdn.ProfilePropertiesCreateParameters{
cdnProfile := cdn.ProfileCreateParameters{
Location: &location,
Tags: expandTags(tags),
Sku: &cdn.Sku{
Name: cdn.SkuName(sku),
},
}

cdnProfile := cdn.ProfileCreateParameters{
Location: &location,
Properties: &properties,
Tags: expandTags(tags),
}

_, err := cdnProfilesClient.Create(name, cdnProfile, resGroup, make(chan struct{}))
if err != nil {
return err
Expand Down Expand Up @@ -110,8 +107,8 @@ func resourceArmCdnProfileRead(d *schema.ResourceData, meta interface{}) error {
return fmt.Errorf("Error making Read request on Azure CDN Profile %s: %s", name, err)
}

if resp.Properties != nil && resp.Properties.Sku != nil {
d.Set("sku", string(resp.Properties.Sku.Name))
if resp.Sku != nil {
d.Set("sku", string(resp.Sku.Name))
}

flattenAndSetTags(d, resp.Tags)
Expand All @@ -134,7 +131,7 @@ func resourceArmCdnProfileUpdate(d *schema.ResourceData, meta interface{}) error
Tags: expandTags(newTags),
}

_, err := cdnProfilesClient.Update(name, props, resGroup)
_, err := cdnProfilesClient.Update(name, props, resGroup, make(chan struct{}))
if err != nil {
return fmt.Errorf("Error issuing Azure ARM update request to update CDN Profile %q: %s", name, err)
}
Expand All @@ -160,12 +157,13 @@ func resourceArmCdnProfileDelete(d *schema.ResourceData, meta interface{}) error
func validateCdnProfileSku(v interface{}, k string) (ws []string, errors []error) {
value := strings.ToLower(v.(string))
skus := map[string]bool{
"standard": true,
"premium": true,
"standard_akamai": true,
"premium_verizon": true,
"standard_verizon": true,
}

if !skus[value] {
errors = append(errors, fmt.Errorf("CDN Profile SKU can only be Standard or Premium"))
errors = append(errors, fmt.Errorf("CDN Profile SKU can only be Premium_Verizon, Standard_Verizon or Standard_Akamai"))
}
return
}
18 changes: 11 additions & 7 deletions builtin/providers/azurerm/resource_arm_cdn_profile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,23 @@ func TestResourceAzureRMCdnProfileSKU_validation(t *testing.T) {
ErrCount: 1,
},
{
Value: "Standard",
Value: "Standard_Verizon",
ErrCount: 0,
},
{
Value: "Premium",
Value: "Premium_Verizon",
ErrCount: 0,
},
{
Value: "STANDARD",
Value: "Standard_Akamai",
ErrCount: 0,
},
{
Value: "PREMIUM",
Value: "STANDARD_AKAMAI",
ErrCount: 0,
},
{
Value: "standard_akamai",
ErrCount: 0,
},
}
Expand Down Expand Up @@ -167,7 +171,7 @@ resource "azurerm_cdn_profile" "test" {
name = "acctestcdnprof%d"
location = "West US"
resource_group_name = "${azurerm_resource_group.test.name}"
sku = "Standard"
sku = "Standard_Verizon"
}
`

Expand All @@ -180,7 +184,7 @@ resource "azurerm_cdn_profile" "test" {
name = "acctestcdnprof%d"
location = "West US"
resource_group_name = "${azurerm_resource_group.test.name}"
sku = "Standard"
sku = "Standard_Verizon"
tags {
environment = "Production"
Expand All @@ -198,7 +202,7 @@ resource "azurerm_cdn_profile" "test" {
name = "acctestcdnprof%d"
location = "West US"
resource_group_name = "${azurerm_resource_group.test.name}"
sku = "Standard"
sku = "Standard_Verizon"
tags {
environment = "staging"
Expand Down
25 changes: 15 additions & 10 deletions builtin/providers/azurerm/resource_arm_storage_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,14 @@ func resourceArmStorageAccountCreate(d *schema.ResourceData, meta interface{}) e
location := d.Get("location").(string)
tags := d.Get("tags").(map[string]interface{})

sku := storage.Sku{
Name: storage.SkuName(accountType),
}

opts := storage.AccountCreateParameters{
Location: &location,
Properties: &storage.AccountPropertiesCreateParameters{
AccountType: storage.AccountType(accountType),
},
Tags: expandTags(tags),
Sku: &sku,
Tags: expandTags(tags),
}

_, err := client.Create(resourceGroupName, storageAccountName, opts, make(chan struct{}))
Expand Down Expand Up @@ -159,10 +161,12 @@ func resourceArmStorageAccountUpdate(d *schema.ResourceData, meta interface{}) e
if d.HasChange("account_type") {
accountType := d.Get("account_type").(string)

sku := storage.Sku{
Name: storage.SkuName(accountType),
}

opts := storage.AccountUpdateParameters{
Properties: &storage.AccountPropertiesUpdateParameters{
AccountType: storage.AccountType(accountType),
},
Sku: &sku,
}
_, err := client.Update(resourceGroupName, storageAccountName, opts)
if err != nil {
Expand Down Expand Up @@ -215,10 +219,11 @@ func resourceArmStorageAccountRead(d *schema.ResourceData, meta interface{}) err
return err
}

d.Set("primary_access_key", keys.Key1)
d.Set("secondary_access_key", keys.Key2)
accessKeys := *keys.Keys
d.Set("primary_access_key", accessKeys[0].KeyName)
d.Set("secondary_access_key", accessKeys[1].KeyName)
d.Set("location", resp.Location)
d.Set("account_type", resp.Properties.AccountType)
d.Set("account_type", resp.Sku.Name)
d.Set("primary_location", resp.Properties.PrimaryLocation)
d.Set("secondary_location", resp.Properties.SecondaryLocation)

Expand Down
5 changes: 3 additions & 2 deletions state/remote/azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,12 @@ func getStorageAccountAccessKey(conf map[string]string, resourceGroupName, stora
return "", fmt.Errorf("Error retrieving keys for storage account %q: %s", storageAccountName, err)
}

if keys.Key1 == nil {
if keys.Keys == nil {
return "", fmt.Errorf("Nil key returned for storage account %q", storageAccountName)
}

return *keys.Key1, nil
accessKeys := *keys.Keys
return *accessKeys[0].KeyName, nil
}

func getCredentialsFromConf(conf map[string]string) (*riviera.AzureResourceManagerCredentials, error) {
Expand Down
15 changes: 6 additions & 9 deletions vendor/github.com/Azure/azure-sdk-for-go/arm/cdn/client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit b9c7ae8

Please sign in to comment.