Skip to content

Commit

Permalink
dependencies: migrate storage_sync resources to `hashicorp/go-azure…
Browse files Browse the repository at this point in the history
…-sdk` (#21928)
  • Loading branch information
katbyte authored Jul 13, 2023
1 parent d6bc225 commit de61c75
Show file tree
Hide file tree
Showing 104 changed files with 3,075 additions and 8,642 deletions.
6 changes: 4 additions & 2 deletions internal/clients/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -497,10 +497,12 @@ func (client *Client) Build(ctx context.Context, o *common.ClientOptions) error
return fmt.Errorf("building clients for SignalR: %+v", err)
}
client.Sql = sql.NewClient(o)
client.Storage = storage.NewClient(o)
if client.StorageMover, err = storageMover.NewClient(o); err != nil {
if client.Storage, err = storage.NewClient(o); err != nil {
return fmt.Errorf("building clients for StorageMover: %+v", err)
}
if client.StorageMover, err = storageMover.NewClient(o); err != nil {
return fmt.Errorf("building Storage for StorageMover: %+v", err)
}
client.StreamAnalytics = streamAnalytics.NewClient(o)
client.Subscription = subscription.NewClient(o)
client.Synapse = synapse.NewClient(o)
Expand Down
44 changes: 27 additions & 17 deletions internal/services/storage/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ import (
"context"
"fmt"

"github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2021-09-01/storage" // nolint: staticcheck
"github.com/Azure/azure-sdk-for-go/services/storagesync/mgmt/2020-03-01/storagesync" // nolint: staticcheck
"github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2021-09-01/storage" // nolint: staticcheck
"github.com/Azure/go-autorest/autorest"
"github.com/Azure/go-autorest/autorest/azure"
storage_v2022_05_01 "github.com/hashicorp/go-azure-sdk/resource-manager/storage/2022-05-01"
"github.com/hashicorp/go-azure-sdk/resource-manager/storage/2022-05-01/localusers"
"github.com/hashicorp/go-azure-sdk/resource-manager/storagesync/2020-03-01/cloudendpointresource"
"github.com/hashicorp/go-azure-sdk/resource-manager/storagesync/2020-03-01/storagesyncservicesresource"
"github.com/hashicorp/go-azure-sdk/resource-manager/storagesync/2020-03-01/syncgroupresource"
"github.com/hashicorp/terraform-provider-azurerm/internal/common"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/storage/shim"
"github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/accounts"
Expand All @@ -36,12 +38,12 @@ type Client struct {
ManagementPoliciesClient *storage.ManagementPoliciesClient
BlobServicesClient *storage.BlobServicesClient
BlobInventoryPoliciesClient *storage.BlobInventoryPoliciesClient
CloudEndpointsClient *storagesync.CloudEndpointsClient
EncryptionScopesClient *storage.EncryptionScopesClient
Environment azure.Environment
FileServicesClient *storage.FileServicesClient
SyncServiceClient *storagesync.ServicesClient
SyncGroupsClient *storagesync.SyncGroupsClient
SyncCloudEndpointsClient *cloudendpointresource.CloudEndpointResourceClient
SyncServiceClient *storagesyncservicesresource.StorageSyncServicesResourceClient
SyncGroupsClient *syncgroupresource.SyncGroupResourceClient
SubscriptionId string

ResourceManager *storage_v2022_05_01.Client
Expand All @@ -50,7 +52,7 @@ type Client struct {
storageAdAuth *autorest.Authorizer
}

func NewClient(options *common.ClientOptions) *Client {
func NewClient(options *common.ClientOptions) (*Client, error) {
accountsClient := storage.NewAccountsClientWithBaseURI(options.ResourceManagerEndpoint, options.SubscriptionId)
options.ConfigureClient(&accountsClient.Client, options.ResourceManagerAuthorizer)

Expand All @@ -72,9 +74,6 @@ func NewClient(options *common.ClientOptions) *Client {
blobInventoryPoliciesClient := storage.NewBlobInventoryPoliciesClientWithBaseURI(options.ResourceManagerEndpoint, options.SubscriptionId)
options.ConfigureClient(&blobInventoryPoliciesClient.Client, options.ResourceManagerAuthorizer)

cloudEndpointsClient := storagesync.NewCloudEndpointsClientWithBaseURI(options.ResourceManagerEndpoint, options.SubscriptionId)
options.ConfigureClient(&cloudEndpointsClient.Client, options.ResourceManagerAuthorizer)

encryptionScopesClient := storage.NewEncryptionScopesClientWithBaseURI(options.ResourceManagerEndpoint, options.SubscriptionId)
options.ConfigureClient(&encryptionScopesClient.Client, options.ResourceManagerAuthorizer)

Expand All @@ -86,11 +85,22 @@ func NewClient(options *common.ClientOptions) *Client {
c.Authorizer = options.ResourceManagerAuthorizer
})

syncServiceClient := storagesync.NewServicesClientWithBaseURI(options.ResourceManagerEndpoint, options.SubscriptionId)
options.ConfigureClient(&syncServiceClient.Client, options.ResourceManagerAuthorizer)
syncCloudEndpointsClient, err := cloudendpointresource.NewCloudEndpointResourceClientWithBaseURI(options.Environment.ResourceManager)
if err != nil {
return nil, fmt.Errorf("building clients for Cloud EndpointsClient Client: %+v", err)
}
options.Configure(syncCloudEndpointsClient.Client, options.Authorizers.ResourceManager)
syncServiceClient, err := storagesyncservicesresource.NewStorageSyncServicesResourceClientWithBaseURI(options.Environment.ResourceManager)
if err != nil {
return nil, fmt.Errorf("building clients for Storage Sync Service Client: %+v", err)
}
options.Configure(syncServiceClient.Client, options.Authorizers.ResourceManager)

syncGroupsClient := storagesync.NewSyncGroupsClientWithBaseURI(options.ResourceManagerEndpoint, options.SubscriptionId)
options.ConfigureClient(&syncGroupsClient.Client, options.ResourceManagerAuthorizer)
syncGroupsClient, err := syncgroupresource.NewSyncGroupResourceClientWithBaseURI(options.Environment.ResourceManager)
if err != nil {
return nil, fmt.Errorf("building clients for Storage Sync Groups Client: %+v", err)
}
options.Configure(syncGroupsClient.Client, options.Authorizers.ResourceManager)

// TODO: switch Storage Containers to using the storage.BlobContainersClient
// (which should fix #2977) when the storage clients have been moved in here
Expand All @@ -102,14 +112,14 @@ func NewClient(options *common.ClientOptions) *Client {
ManagementPoliciesClient: &managementPoliciesClient,
BlobServicesClient: &blobServicesClient,
BlobInventoryPoliciesClient: &blobInventoryPoliciesClient,
CloudEndpointsClient: &cloudEndpointsClient,
EncryptionScopesClient: &encryptionScopesClient,
Environment: options.AzureEnvironment,
FileServicesClient: &fileServicesClient,
ResourceManager: &resourceManager,
SubscriptionId: options.SubscriptionId,
SyncServiceClient: &syncServiceClient,
SyncGroupsClient: &syncGroupsClient,
SyncCloudEndpointsClient: syncCloudEndpointsClient,
SyncServiceClient: syncServiceClient,
SyncGroupsClient: syncGroupsClient,

resourceManagerAuthorizer: options.ResourceManagerAuthorizer,
}
Expand All @@ -118,7 +128,7 @@ func NewClient(options *common.ClientOptions) *Client {
client.storageAdAuth = &options.StorageAuthorizer
}

return &client
return &client, nil
}

func (client Client) AccountsDataPlaneClient(ctx context.Context, account accountDetails) (*accounts.Client, error) {
Expand Down
84 changes: 0 additions & 84 deletions internal/services/storage/parse/storage_sync_cloud_endpoint.go

This file was deleted.

147 changes: 0 additions & 147 deletions internal/services/storage/parse/storage_sync_cloud_endpoint_test.go

This file was deleted.

Loading

0 comments on commit de61c75

Please sign in to comment.