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

azurerm_storage_account: set queue_properties #3859

Merged
merged 10 commits into from
Jul 23, 2019
Merged
Show file tree
Hide file tree
Changes from 9 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
8 changes: 8 additions & 0 deletions azurerm/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,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 @@ -348,6 +355,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