Skip to content

Commit

Permalink
azurerm_storage_account: set queue_properties (#3859)
Browse files Browse the repository at this point in the history
  • Loading branch information
mbfrahry authored Jul 23, 2019
1 parent ee461e2 commit 52d9184
Show file tree
Hide file tree
Showing 12 changed files with 684 additions and 135 deletions.
8 changes: 8 additions & 0 deletions azurerm/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,13 @@ func getArmClient(c *authentication.Config, skipProviderRegistration bool, partn
return nil, err
}

// Storage Endpoints
storageEndpoint := env.ResourceIdentifiers.Storage
storageAuth, err := c.GetAuthorizationToken(sender, oauthConfig, storageEndpoint)
if err != nil {
return nil, err
}

// Key Vault Endpoints
keyVaultAuth := autorest.NewBearerAuthorizerCallback(sender, func(tenantID, resource string) (*autorest.BearerAuthorizer, error) {
keyVaultSpt, err := c.GetAuthorizationToken(sender, oauthConfig, resource)
Expand All @@ -355,6 +362,7 @@ func getArmClient(c *authentication.Config, skipProviderRegistration bool, partn
KeyVaultAuthorizer: keyVaultAuth,
ResourceManagerAuthorizer: auth,
ResourceManagerEndpoint: endpoint,
StorageAuthorizer: storageAuth,
SubscriptionId: c.SubscriptionID,
PartnerId: partnerId,
PollingDuration: 60 * time.Minute,
Expand Down
1 change: 1 addition & 0 deletions azurerm/internal/common/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ type ClientOptions struct {
KeyVaultAuthorizer autorest.Authorizer
ResourceManagerAuthorizer autorest.Authorizer
ResourceManagerEndpoint string
StorageAuthorizer autorest.Authorizer
SubscriptionId string
PartnerId string
PollingDuration time.Duration
Expand Down
18 changes: 6 additions & 12 deletions azurerm/internal/services/storage/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
)

type Client struct {
QueuesClient queues.Client
// this is currently unexported since we only use it to look up the account key
// we could export/use this in the future - but there's no point it being public
// until that time
Expand All @@ -30,11 +31,16 @@ type Client struct {
// NOTE: this temporarily diverges from the other clients until we move this client in here
// once we have this, can take an Options like everything else
func BuildClient(accountsClient storage.AccountsClient, options *common.ClientOptions) *Client {
queuesClient := queues.New()
options.ConfigureClient(&queuesClient.Client, options.StorageAuthorizer)

// TODO: switch Storage Containers to using the storage.BlobContainersClient
// (which should fix #2977) when the storage clients have been moved in here
return &Client{
accountsClient: accountsClient,
environment: options.Environment,

QueuesClient: queuesClient,
}
}

Expand Down Expand Up @@ -116,18 +122,6 @@ func (client Client) FileSharesClient(ctx context.Context, resourceGroup, accoun
return &directoriesClient, nil
}

func (client Client) QueuesClient(ctx context.Context, resourceGroup, accountName string) (*queues.Client, error) {
accountKey, err := client.findAccountKey(ctx, resourceGroup, accountName)
if err != nil {
return nil, fmt.Errorf("Error retrieving Account Key: %s", err)
}

storageAuth := authorizers.NewSharedKeyLiteAuthorizer(accountName, *accountKey)
queuesClient := queues.NewWithEnvironment(client.environment)
queuesClient.Client.Authorizer = storageAuth
return &queuesClient, nil
}

func (client Client) TableEntityClient(ctx context.Context, resourceGroup, accountName string) (*entities.Client, error) {
accountKey, err := client.findAccountKey(ctx, resourceGroup, accountName)
if err != nil {
Expand Down
Loading

0 comments on commit 52d9184

Please sign in to comment.