Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update vendor of Azure/azure-sdk-for-go to v21.1.0 #18968

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions backend/remote-state/azure/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"fmt"

armStorage "github.com/Azure/azure-sdk-for-go/arm/storage"
armStorage "github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2017-06-01/storage"
"github.com/Azure/azure-sdk-for-go/storage"
"github.com/Azure/go-autorest/autorest"
"github.com/Azure/go-autorest/autorest/adal"
Expand All @@ -13,7 +13,7 @@ import (
"github.com/hashicorp/terraform/helper/schema"
)

// New creates a new backend for S3 remote state.
// New creates a new backend for Azure Blob Storage remote state.
func New() backend.Backend {
s := &schema.Backend{
Schema: map[string]*schema.Schema{
Expand Down Expand Up @@ -193,7 +193,7 @@ func getAccessKey(config BackendConfig, env azure.Environment) (string, error) {
accountsClient := armStorage.NewAccountsClientWithBaseURI(env.ResourceManagerEndpoint, config.SubscriptionID)
accountsClient.Authorizer = autorest.NewBearerAuthorizer(spt)

keys, err := accountsClient.ListKeys(config.ResourceGroupName, config.StorageAccountName)
keys, err := accountsClient.ListKeys(context.Background(), config.ResourceGroupName, config.StorageAccountName)
if err != nil {
return "", fmt.Errorf("Error retrieving keys for storage account %q: %s", config.StorageAccountName, err)
}
Expand Down
44 changes: 31 additions & 13 deletions backend/remote-state/azure/backend_test.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package azure

import (
"context"
"fmt"
"os"
"testing"
"time"

"github.com/Azure/azure-sdk-for-go/arm/resources/resources"
armStorage "github.com/Azure/azure-sdk-for-go/arm/storage"
"github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2017-05-10/resources"
armStorage "github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2017-06-01/storage"
"github.com/Azure/azure-sdk-for-go/storage"
"github.com/Azure/go-autorest/autorest"
"github.com/Azure/go-autorest/autorest/adal"
Expand Down Expand Up @@ -54,7 +56,7 @@ func TestBackend(t *testing.T) {
testACC(t)

keyName := "testState"
res := setupResources(t, keyName)
res := setupResources(t, context.Background(), keyName)
defer destroyResources(t, res.resourceGroupName)

b := backend.TestBackendConfig(t, New(), map[string]interface{}{
Expand All @@ -71,7 +73,7 @@ func TestBackendLocked(t *testing.T) {
testACC(t)

keyName := "testState"
res := setupResources(t, keyName)
res := setupResources(t, context.Background(), keyName)
defer destroyResources(t, res.resourceGroupName)

b1 := backend.TestBackendConfig(t, New(), map[string]interface{}{
Expand Down Expand Up @@ -100,7 +102,7 @@ type testResources struct {
accessKey string
}

func setupResources(t *testing.T, keyName string) testResources {
func setupResources(t *testing.T, ctx context.Context, keyName string) testResources {
clients := getTestClient(t)

ri := acctest.RandInt()
Expand All @@ -118,27 +120,39 @@ func setupResources(t *testing.T, keyName string) testResources {
}

t.Logf("creating resource group %s", res.resourceGroupName)
_, err := clients.groupsClient.CreateOrUpdate(res.resourceGroupName, resources.Group{Location: &location})
resourceGroup, err := clients.groupsClient.CreateOrUpdate(ctx, res.resourceGroupName, resources.Group{Location: &location})
if err != nil {
t.Fatalf("failed to create test resource group: %s", err)
} else {
t.Logf("Created resource group: %s", *resourceGroup.Name)
}

t.Logf("creating storage account %s", res.storageAccountName)
_, createError := clients.storageAccountsClient.Create(res.resourceGroupName, res.storageAccountName, armStorage.AccountCreateParameters{
storageAccountFuture, err := clients.storageAccountsClient.Create(ctx, res.resourceGroupName, res.storageAccountName, armStorage.AccountCreateParameters{
Sku: &armStorage.Sku{
Name: armStorage.StandardLRS,
Tier: armStorage.Standard,
},
Location: &location,
}, make(chan struct{}))
createErr := <-createError
if createErr != nil {
})

if err != nil {
destroyResources(t, res.resourceGroupName)
t.Fatalf("failed to submit storage account creation: %s", err)
}

oneMinWaitCtx, cancelSAWait := context.WithTimeout(ctx, 1*time.Minute)
defer cancelSAWait()
err = storageAccountFuture.WaitForCompletionRef(oneMinWaitCtx, clients.storageAccountsClient.BaseClient.Client)
if err != nil {
destroyResources(t, res.resourceGroupName)
t.Fatalf("failed to create test storage account: %s", err)
} else {
t.Logf("Created storage account %s", res.storageAccountName)
}

t.Log("fetching access key for storage account")
resp, err := clients.storageAccountsClient.ListKeys(res.resourceGroupName, res.storageAccountName)
resp, err := clients.storageAccountsClient.ListKeys(ctx, res.resourceGroupName, res.storageAccountName)
if err != nil {
destroyResources(t, res.resourceGroupName)
t.Fatalf("failed to list storage account keys %s:", err)
Expand Down Expand Up @@ -174,8 +188,12 @@ func destroyResources(t *testing.T, resourceGroupName string) {
t.Log("destroying created resources")

// destroying is simple as deleting the resource group will destroy everything else
_, deleteErr := clients.groupsClient.Delete(resourceGroupName, make(chan struct{}))
err := <-deleteErr
future, err := clients.groupsClient.Delete(context.Background(), resourceGroupName)
if err != nil {
t.Logf(warning, err)
return
}
err = future.WaitForCompletion(context.Background(), clients.groupsClient.BaseClient.Client)
if err != nil {
t.Logf(warning, err)
return
Expand Down
7 changes: 4 additions & 3 deletions backend/remote-state/azure/client_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package azure

import (
"context"
"testing"

"github.com/Azure/azure-sdk-for-go/storage"
Expand All @@ -18,7 +19,7 @@ func TestRemoteClient(t *testing.T) {
testACC(t)

keyName := "testState"
res := setupResources(t, keyName)
res := setupResources(t, context.Background(), keyName)
defer destroyResources(t, res.resourceGroupName)

b := backend.TestBackendConfig(t, New(), map[string]interface{}{
Expand All @@ -40,7 +41,7 @@ func TestRemoteClientLocks(t *testing.T) {
testACC(t)

keyName := "testState"
res := setupResources(t, keyName)
res := setupResources(t, context.Background(), keyName)
defer destroyResources(t, res.resourceGroupName)

b1 := backend.TestBackendConfig(t, New(), map[string]interface{}{
Expand Down Expand Up @@ -76,7 +77,7 @@ func TestPutMaintainsMetaData(t *testing.T) {
keyName := "testState"
headerName := "acceptancetest"
expectedValue := "f3b56bad-33ad-4b93-a600-7a66e9cbd1eb"
res := setupResources(t, keyName)
res := setupResources(t, context.Background(), keyName)
defer destroyResources(t, res.resourceGroupName)

config := getBackendConfig(t, res)
Expand Down
5 changes: 5 additions & 0 deletions vendor/github.com/Azure/azure-sdk-for-go/NOTICE

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

Loading