Skip to content

Commit

Permalink
[#3319] datalakestore gen2 filesystem resource
Browse files Browse the repository at this point in the history
  • Loading branch information
tcz001 committed Sep 30, 2019
1 parent 7375bee commit 30a4dd3
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 4 deletions.
8 changes: 8 additions & 0 deletions azurerm/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,13 @@ func getArmClient(authConfig *authentication.Config, skipProviderRegistration bo
// Storage Endpoints
storageAuth := authConfig.BearerAuthorizerCallback(sender, oauthConfig)

// Filesystem Endpoints
filesystemEndpoint := env.ResourceIdentifiers.Storage
filesystemAuth, err := authConfig.GetAuthorizationToken(sender, oauthConfig, filesystemEndpoint)
if err != nil {
return nil, err
}

// Key Vault Endpoints
keyVaultAuth := authConfig.BearerAuthorizerCallback(sender, oauthConfig)

Expand All @@ -207,6 +214,7 @@ func getArmClient(authConfig *authentication.Config, skipProviderRegistration bo
ResourceManagerAuthorizer: auth,
ResourceManagerEndpoint: endpoint,
StorageAuthorizer: storageAuth,
FilesystemAuthorizer: filesystemAuth,
PollingDuration: 180 * time.Minute,
SkipProviderReg: skipProviderRegistration,
DisableCorrelationRequestID: disableCorrelationRequestID,
Expand Down
1 change: 1 addition & 0 deletions azurerm/internal/common/client_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ type ClientOptions struct {
ResourceManagerAuthorizer autorest.Authorizer
ResourceManagerEndpoint string
StorageAuthorizer autorest.Authorizer
FilesystemAuthorizer autorest.Authorizer

PollingDuration time.Duration
SkipProviderReg bool
Expand Down
18 changes: 15 additions & 3 deletions azurerm/internal/services/storage/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@ import (
"context"
"fmt"

"github.com/Azure/go-autorest/autorest"

"github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2019-04-01/storage"
az "github.com/Azure/go-autorest/autorest/azure"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/authorizers"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/common"
"github.com/tombuildsstuff/giovanni/storage/2018-11-09/blob/blobs"
"github.com/tombuildsstuff/giovanni/storage/2018-11-09/blob/containers"
"github.com/tombuildsstuff/giovanni/storage/2018-11-09/datalakestore/filesystems"
"github.com/tombuildsstuff/giovanni/storage/2018-11-09/file/directories"
"github.com/tombuildsstuff/giovanni/storage/2018-11-09/file/shares"
"github.com/tombuildsstuff/giovanni/storage/2018-11-09/queue/queues"
Expand All @@ -18,7 +21,8 @@ import (
)

type Client struct {
AccountsClient storage.AccountsClient
AccountsClient storage.AccountsClient
FilesystemAuthorizer autorest.Authorizer

environment az.Environment
}
Expand All @@ -30,8 +34,9 @@ func BuildClient(options *common.ClientOptions) *Client {
// 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,
AccountsClient: accountsClient,
FilesystemAuthorizer: options.FilesystemAuthorizer,
environment: options.Environment,
}
}

Expand Down Expand Up @@ -59,6 +64,13 @@ func (client Client) ContainersClient(ctx context.Context, resourceGroup, accoun
return &containersClient, nil
}

func (client Client) FileSystemsClient(ctx context.Context, resourceGroup, accountName string) (*filesystems.Client, error) {
filesystemAuth := client.FilesystemAuthorizer
fileSystemsClient := filesystems.NewWithEnvironment(client.environment)
fileSystemsClient.Client.Authorizer = filesystemAuth
return &fileSystemsClient, nil
}

func (client Client) FileShareDirectoriesClient(ctx context.Context, resourceGroup, accountName string) (*directories.Client, error) {
accountKey, err := client.findAccountKey(ctx, resourceGroup, accountName)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions azurerm/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,7 @@ func Provider() terraform.ResourceProvider {
"azurerm_storage_share_directory": resourceArmStorageShareDirectory(),
"azurerm_storage_table": resourceArmStorageTable(),
"azurerm_storage_table_entity": resourceArmStorageTableEntity(),
"azurerm_storage_filesystem": resourceArmStorageFilesystem(),
"azurerm_stream_analytics_job": resourceArmStreamAnalyticsJob(),
"azurerm_stream_analytics_function_javascript_udf": resourceArmStreamAnalyticsFunctionUDF(),
"azurerm_stream_analytics_output_blob": resourceArmStreamAnalyticsOutputBlob(),
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ require (
github.com/satori/go.uuid v1.2.0
github.com/satori/uuid v0.0.0-20160927100844-b061729afc07
github.com/terraform-providers/terraform-provider-azuread v0.6.0
github.com/tombuildsstuff/giovanni v0.5.0
github.com/tombuildsstuff/giovanni v0.6.0
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4
golang.org/x/net v0.0.0-20190502183928-7f726cade0ab
gopkg.in/yaml.v2 v2.2.2
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,8 @@ github.com/terraform-providers/terraform-provider-openstack v1.15.0/go.mod h1:2a
github.com/tmc/grpc-websocket-proxy v0.0.0-20171017195756-830351dc03c6/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
github.com/tombuildsstuff/giovanni v0.5.0 h1:ih4qTvjOOAHubTdINDWtrTpHyHNzrqam4xcIWQY9A1A=
github.com/tombuildsstuff/giovanni v0.5.0/go.mod h1:Xu/XU+DiRrKTDoCnJNGuh9ysD0eJyi/zU/naFh2aN9I=
github.com/tombuildsstuff/giovanni v0.6.0 h1:8RwaDJJqbp8mMN/HOKEbGUvhW/yaGMzxN2XbkQ3lHuA=
github.com/tombuildsstuff/giovanni v0.6.0/go.mod h1:Xu/XU+DiRrKTDoCnJNGuh9ysD0eJyi/zU/naFh2aN9I=
github.com/ugorji/go v0.0.0-20180813092308-00b869d2f4a5 h1:cMjKdf4PxEBN9K5HaD9UMW8gkTbM0kMzkTa9SJe0WNQ=
github.com/ugorji/go v0.0.0-20180813092308-00b869d2f4a5/go.mod h1:hnLbHMwcvSihnDhEfx2/BzKp2xb0Y+ErdfYcrs9tkJQ=
github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8 h1:3SVOIvH7Ae1KRYyQWRjXWJEA9sS/c/pjvH++55Gr648=
Expand Down

0 comments on commit 30a4dd3

Please sign in to comment.