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

deps: Upgrade Azure SDK for Go #6976

Merged
merged 17 commits into from
Jun 2, 2016
Merged
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
115 changes: 70 additions & 45 deletions Godeps/Godeps.json

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

2 changes: 1 addition & 1 deletion builtin/providers/azure/resource_azure_storage_blob.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ func resourceAzureStorageBlobDelete(d *schema.ResourceData, meta interface{}) er
log.Println("[INFO] Issuing storage blob delete command off Azure.")
name := d.Get("name").(string)
cont := d.Get("storage_container_name").(string)
if _, err = blobClient.DeleteBlobIfExists(cont, name); err != nil {
if _, err = blobClient.DeleteBlobIfExists(cont, name, make(map[string]string)); err != nil {
return fmt.Errorf("Error whilst deleting storage blob: %s", err)
}

Expand Down
42 changes: 21 additions & 21 deletions builtin/providers/azurerm/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,16 @@ import (
"fmt"
"log"
"net/http"
"time"

"github.com/Azure/azure-sdk-for-go/Godeps/_workspace/src/github.com/Azure/go-autorest/autorest"
"github.com/Azure/azure-sdk-for-go/Godeps/_workspace/src/github.com/Azure/go-autorest/autorest/azure"
"github.com/Azure/azure-sdk-for-go/arm/cdn"
"github.com/Azure/azure-sdk-for-go/arm/compute"
"github.com/Azure/azure-sdk-for-go/arm/network"
"github.com/Azure/azure-sdk-for-go/arm/resources/resources"
"github.com/Azure/azure-sdk-for-go/arm/scheduler"
"github.com/Azure/azure-sdk-for-go/arm/storage"
mainStorage "github.com/Azure/azure-sdk-for-go/storage"
"github.com/Azure/go-autorest/autorest"
"github.com/Azure/go-autorest/autorest/azure"
"github.com/hashicorp/terraform/terraform"
riviera "github.com/jen20/riviera/azure"
)
Expand Down Expand Up @@ -77,22 +76,6 @@ func withRequestLogging() autorest.SendDecorator {
}
}

func withPollWatcher() autorest.SendDecorator {
return func(s autorest.Sender) autorest.Sender {
return autorest.SenderFunc(func(r *http.Request) (*http.Response, error) {
fmt.Printf("[DEBUG] Sending Azure RM Request %q to %q\n", r.Method, r.URL)
resp, err := s.Do(r)
fmt.Printf("[DEBUG] Received Azure RM Request status code %s for %s\n", resp.Status, r.URL)
if autorest.ResponseRequiresPolling(resp) {
fmt.Printf("[DEBUG] Azure RM request will poll %s after %d seconds\n",
autorest.GetPollingLocation(resp),
int(autorest.GetPollingDelay(resp, time.Duration(0))/time.Second))
}
return resp, err
})
}
}

func setUserAgent(client *autorest.Client) {
var version string
if terraform.VersionPrerelease != "" {
Expand Down Expand Up @@ -130,7 +113,23 @@ func (c *Config) getArmClient() (*ArmClient, error) {
}
client.rivieraClient = rivieraClient

spt, err := azure.NewServicePrincipalToken(c.ClientID, c.ClientSecret, c.TenantID, azure.AzureResourceManagerScope)
oauthConfig, err := azure.PublicCloud.OAuthConfigForTenant(c.TenantID)
if err != nil {
return nil, err
}

// This is necessary because no-one thought about API usability. OAuthConfigForTenant
// returns a pointer, which can be nil. NewServicePrincipalToken does not take a pointer.
// Consequently we have to nil check this and do _something_ if it is nil, which should
// be either an invariant of OAuthConfigForTenant (guarantee the token is not nil if
// there is no error), or NewServicePrincipalToken should error out if the configuration
// is required and is nil. This is the worst of all worlds, however.
if oauthConfig == nil {
return nil, fmt.Errorf("Unable to configure OAuthConfig for tenant %s", c.TenantID)
}

spt, err := azure.NewServicePrincipalToken(*oauthConfig, c.ClientID, c.ClientSecret,
azure.PublicCloud.ResourceManagerEndpoint)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -284,7 +283,7 @@ func (c *Config) getArmClient() (*ArmClient, error) {
ssc := storage.NewAccountsClient(c.SubscriptionID)
setUserAgent(&ssc.Client)
ssc.Authorizer = spt
ssc.Sender = autorest.CreateSender(withRequestLogging(), withPollWatcher())
ssc.Sender = autorest.CreateSender(withRequestLogging())
client.storageServiceClient = ssc

suc := storage.NewUsageOperationsClient(c.SubscriptionID)
Expand Down Expand Up @@ -349,6 +348,7 @@ func (armClient *ArmClient) getBlobStorageClientForStorageAccount(resourceGroupN
blobClient := storageClient.GetBlobService()
return &blobClient, true, nil
}

func (armClient *ArmClient) getQueueServiceClientForStorageAccount(resourceGroupName, storageAccountName string) (*mainStorage.QueueServiceClient, bool, error) {
key, accountExists, err := armClient.getKeyForStorageAccount(resourceGroupName, storageAccountName)
if err != nil {
Expand Down
Loading