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

r/storage_share: switching to use the new storage sdk #3828

Merged
merged 8 commits into from
Jul 11, 2019
Merged
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
19 changes: 0 additions & 19 deletions azurerm/config.go
Original file line number Diff line number Diff line change
@@ -1237,25 +1237,6 @@ func (c *ArmClient) getBlobStorageClientForStorageAccount(ctx context.Context, r
return &blobClient, true, nil
}

func (c *ArmClient) getFileServiceClientForStorageAccount(ctx context.Context, resourceGroupName, storageAccountName string) (*mainStorage.FileServiceClient, bool, error) {
key, accountExists, err := c.getKeyForStorageAccount(ctx, resourceGroupName, storageAccountName)
if err != nil {
return nil, accountExists, err
}
if !accountExists {
return nil, false, nil
}

storageClient, err := mainStorage.NewClient(storageAccountName, key, c.environment.StorageEndpointSuffix,
mainStorage.DefaultAPIVersion, true)
if err != nil {
return nil, true, fmt.Errorf("Error creating storage client for storage storeAccount %q: %s", storageAccountName, err)
}

fileClient := storageClient.GetFileService()
return &fileClient, true, nil
}

func (c *ArmClient) getTableServiceClientForStorageAccount(ctx context.Context, resourceGroupName, storageAccountName string) (*mainStorage.TableServiceClient, bool, error) {
key, accountExists, err := c.getKeyForStorageAccount(ctx, resourceGroupName, storageAccountName)
if err != nil {
9 changes: 9 additions & 0 deletions azurerm/helpers/azure/resource_group.go
Original file line number Diff line number Diff line change
@@ -18,6 +18,15 @@ func SchemaResourceGroupName() *schema.Schema {
}
}

func SchemaResourceGroupNameDeprecated() *schema.Schema {
return &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
Deprecated: "This field has been deprecated and is no longer used - will be removed in 2.0 of the Azure Provider",
}
}

func SchemaResourceGroupNameDiffSuppress() *schema.Schema {
return &schema.Schema{
Type: schema.TypeString,
15 changes: 14 additions & 1 deletion azurerm/internal/services/storage/client.go
Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@ import (
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/authorizers"
"github.com/tombuildsstuff/giovanni/storage/2018-11-09/file/directories"
"github.com/tombuildsstuff/giovanni/storage/2018-11-09/file/shares"
)

type Client struct {
@@ -56,7 +57,7 @@ func (client Client) FindResourceGroup(ctx context.Context, accountName string)
return resourceGroup, nil
}

func (client Client) FileShareClient(ctx context.Context, resourceGroup, accountName string) (*directories.Client, error) {
func (client Client) FileShareDirectoriesClient(ctx context.Context, resourceGroup, accountName string) (*directories.Client, error) {
accountKey, err := client.findAccountKey(ctx, resourceGroup, accountName)
if err != nil {
return nil, fmt.Errorf("Error retrieving Account Key: %s", err)
@@ -68,6 +69,18 @@ func (client Client) FileShareClient(ctx context.Context, resourceGroup, account
return &directoriesClient, nil
}

func (client Client) FileSharesClient(ctx context.Context, resourceGroup, accountName string) (*shares.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)
directoriesClient := shares.New()
directoriesClient.Client.Authorizer = storageAuth
return &directoriesClient, nil
}

func (client Client) findAccountKey(ctx context.Context, resourceGroup, accountName string) (*string, error) {
props, err := client.accountsClient.ListKeys(ctx, resourceGroup, accountName)
if err != nil {
Loading