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

dependencies: migrate storage_sync resources to hashicorp/go-azure-sdk #21928

Merged
merged 10 commits into from
Jul 13, 2023
Merged
Show file tree
Hide file tree
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
6 changes: 4 additions & 2 deletions internal/clients/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -487,10 +487,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