From 02bd31222f2d0df1cc54a60f9acb1a8f8a963885 Mon Sep 17 00:00:00 2001 From: tombuildsstuff Date: Fri, 15 Mar 2024 11:11:33 +0100 Subject: [PATCH 1/4] `storage`: cleanup --- internal/services/storage/client/client.go | 6 ------ 1 file changed, 6 deletions(-) diff --git a/internal/services/storage/client/client.go b/internal/services/storage/client/client.go index c5d47935bc7f..8fae0e25afc7 100644 --- a/internal/services/storage/client/client.go +++ b/internal/services/storage/client/client.go @@ -7,7 +7,6 @@ import ( "fmt" "github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2021-09-01/storage" // nolint: staticcheck - "github.com/Azure/go-autorest/autorest/azure" storage_v2023_01_01 "github.com/hashicorp/go-azure-sdk/resource-manager/storage/2023-01-01" "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" @@ -21,8 +20,6 @@ import ( var StorageDomainSuffix *string type Client struct { - SubscriptionId string - AccountsClient *storage.AccountsClient BlobInventoryPoliciesClient *storage.BlobInventoryPoliciesClient BlobServicesClient *storage.BlobServicesClient @@ -34,7 +31,6 @@ type Client struct { ResourceManager *storage_v2023_01_01.Client - AzureEnvironment azure.Environment StorageDomainSuffix string authorizerForAad auth.Authorizer @@ -97,12 +93,10 @@ func NewClient(o *common.ClientOptions) (*Client, error) { EncryptionScopesClient: &encryptionScopesClient, FileServicesClient: &fileServicesClient, ResourceManager: resourceManager, - SubscriptionId: o.SubscriptionId, SyncCloudEndpointsClient: syncCloudEndpointsClient, SyncServiceClient: syncServiceClient, SyncGroupsClient: syncGroupsClient, - AzureEnvironment: o.AzureEnvironment, StorageDomainSuffix: *storageSuffix, } From bc1852661c157f415b303865f5a9b3b415e7af36 Mon Sep 17 00:00:00 2001 From: tombuildsstuff Date: Fri, 15 Mar 2024 11:48:51 +0100 Subject: [PATCH 2/4] r/blob_inventory_policy: refactoring to use `hashicorp/go-azure-sdk` --- internal/services/storage/client/client.go | 36 +- .../blob_inventory_policy_v0_to_v1.go | 134 +++++++ .../storage/parse/blob_inventory_policy.go | 78 ---- .../parse/blob_inventory_policy_test.go | 131 ------- internal/services/storage/resourceids.go | 1 - .../storage_blob_inventory_policy_resource.go | 343 +++++++++--------- ...age_blob_inventory_policy_resource_test.go | 28 +- .../validate/blob_inventory_policy_id.go | 26 -- .../validate/blob_inventory_policy_id_test.go | 91 ----- 9 files changed, 333 insertions(+), 535 deletions(-) create mode 100644 internal/services/storage/migration/blob_inventory_policy_v0_to_v1.go delete mode 100644 internal/services/storage/parse/blob_inventory_policy.go delete mode 100644 internal/services/storage/parse/blob_inventory_policy_test.go delete mode 100644 internal/services/storage/validate/blob_inventory_policy_id.go delete mode 100644 internal/services/storage/validate/blob_inventory_policy_id_test.go diff --git a/internal/services/storage/client/client.go b/internal/services/storage/client/client.go index 8fae0e25afc7..54f900971d61 100644 --- a/internal/services/storage/client/client.go +++ b/internal/services/storage/client/client.go @@ -20,14 +20,13 @@ import ( var StorageDomainSuffix *string type Client struct { - AccountsClient *storage.AccountsClient - BlobInventoryPoliciesClient *storage.BlobInventoryPoliciesClient - BlobServicesClient *storage.BlobServicesClient - EncryptionScopesClient *storage.EncryptionScopesClient - FileServicesClient *storage.FileServicesClient - SyncCloudEndpointsClient *cloudendpointresource.CloudEndpointResourceClient - SyncGroupsClient *syncgroupresource.SyncGroupResourceClient - SyncServiceClient *storagesyncservicesresource.StorageSyncServicesResourceClient + AccountsClient *storage.AccountsClient + BlobServicesClient *storage.BlobServicesClient + EncryptionScopesClient *storage.EncryptionScopesClient + FileServicesClient *storage.FileServicesClient + SyncCloudEndpointsClient *cloudendpointresource.CloudEndpointResourceClient + SyncGroupsClient *syncgroupresource.SyncGroupResourceClient + SyncServiceClient *storagesyncservicesresource.StorageSyncServicesResourceClient ResourceManager *storage_v2023_01_01.Client @@ -51,9 +50,6 @@ func NewClient(o *common.ClientOptions) (*Client, error) { blobServicesClient := storage.NewBlobServicesClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) o.ConfigureClient(&blobServicesClient.Client, o.ResourceManagerAuthorizer) - blobInventoryPoliciesClient := storage.NewBlobInventoryPoliciesClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) - o.ConfigureClient(&blobInventoryPoliciesClient.Client, o.ResourceManagerAuthorizer) - encryptionScopesClient := storage.NewEncryptionScopesClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) o.ConfigureClient(&encryptionScopesClient.Client, o.ResourceManagerAuthorizer) @@ -72,6 +68,7 @@ func NewClient(o *common.ClientOptions) (*Client, error) { return nil, fmt.Errorf("building CloudEndpoint client: %+v", err) } o.Configure(syncCloudEndpointsClient.Client, o.Authorizers.ResourceManager) + syncServiceClient, err := storagesyncservicesresource.NewStorageSyncServicesResourceClientWithBaseURI(o.Environment.ResourceManager) if err != nil { return nil, fmt.Errorf("building StorageSyncService client: %+v", err) @@ -87,15 +84,14 @@ func NewClient(o *common.ClientOptions) (*Client, error) { // TODO: switch Storage Containers to using the storage.BlobContainersClient // (which should fix #2977) when the storage clients have been moved in here client := Client{ - AccountsClient: &accountsClient, - BlobServicesClient: &blobServicesClient, - BlobInventoryPoliciesClient: &blobInventoryPoliciesClient, - EncryptionScopesClient: &encryptionScopesClient, - FileServicesClient: &fileServicesClient, - ResourceManager: resourceManager, - SyncCloudEndpointsClient: syncCloudEndpointsClient, - SyncServiceClient: syncServiceClient, - SyncGroupsClient: syncGroupsClient, + AccountsClient: &accountsClient, + BlobServicesClient: &blobServicesClient, + EncryptionScopesClient: &encryptionScopesClient, + FileServicesClient: &fileServicesClient, + ResourceManager: resourceManager, + SyncCloudEndpointsClient: syncCloudEndpointsClient, + SyncServiceClient: syncServiceClient, + SyncGroupsClient: syncGroupsClient, StorageDomainSuffix: *storageSuffix, } diff --git a/internal/services/storage/migration/blob_inventory_policy_v0_to_v1.go b/internal/services/storage/migration/blob_inventory_policy_v0_to_v1.go new file mode 100644 index 000000000000..068c399f8dbb --- /dev/null +++ b/internal/services/storage/migration/blob_inventory_policy_v0_to_v1.go @@ -0,0 +1,134 @@ +package migration + +import ( + "context" + "log" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" +) + +type BlobInventoryPolicyV0ToV1 struct { +} + +func (BlobInventoryPolicyV0ToV1) Schema() map[string]*pluginsdk.Schema { + return map[string]*pluginsdk.Schema{ + "storage_account_id": { + Type: pluginsdk.TypeString, + Required: true, + ForceNew: true, + }, + + "rules": { + Type: pluginsdk.TypeSet, + Required: true, + Elem: &pluginsdk.Resource{ + Schema: map[string]*pluginsdk.Schema{ + "name": { + Type: pluginsdk.TypeString, + Required: true, + }, + + "storage_container_name": { + Type: pluginsdk.TypeString, + Required: true, + }, + + "format": { + Type: pluginsdk.TypeString, + Required: true, + }, + + "schedule": { + Type: pluginsdk.TypeString, + Required: true, + }, + + "scope": { + Type: pluginsdk.TypeString, + Required: true, + }, + + "schema_fields": { + Type: pluginsdk.TypeList, + Required: true, + Elem: &pluginsdk.Schema{ + Type: pluginsdk.TypeString, + }, + }, + + "filter": { + Type: pluginsdk.TypeList, + Optional: true, + MaxItems: 1, + Elem: &pluginsdk.Resource{ + Schema: map[string]*pluginsdk.Schema{ + "blob_types": { + Type: pluginsdk.TypeSet, + Required: true, + Elem: &pluginsdk.Schema{ + Type: pluginsdk.TypeString, + }, + }, + + "include_blob_versions": { + Type: pluginsdk.TypeBool, + Optional: true, + Default: false, + }, + + "include_deleted": { + Type: pluginsdk.TypeBool, + Optional: true, + Default: false, + }, + + "include_snapshots": { + Type: pluginsdk.TypeBool, + Optional: true, + Default: false, + }, + + "prefix_match": { + Type: pluginsdk.TypeSet, + Optional: true, + MaxItems: 10, + Elem: &pluginsdk.Schema{ + Type: pluginsdk.TypeString, + }, + }, + + "exclude_prefixes": { + Type: pluginsdk.TypeSet, + Optional: true, + MaxItems: 10, + Elem: &pluginsdk.Schema{ + Type: pluginsdk.TypeString, + }, + }, + }, + }, + }, + }, + }, + }, + } +} + +func (BlobInventoryPolicyV0ToV1) UpgradeFunc() pluginsdk.StateUpgraderFunc { + return func(ctx context.Context, rawState map[string]interface{}, meta interface{}) (map[string]interface{}, error) { + oldIdRaw := rawState["id"].(string) + + // This now uses the Storage Account ID since it's a 1:1 resource + storageAccountIdRaw := rawState["storage_account_id"].(string) + newId, err := commonids.ParseStorageAccountID(storageAccountIdRaw) + if err != nil { + return nil, err + } + newIdRaw := newId.ID() + + log.Printf("[DEBUG] Updating the Resource ID from %q to %q", oldIdRaw, newIdRaw) + rawState["id"] = newIdRaw + return rawState, nil + } +} diff --git a/internal/services/storage/parse/blob_inventory_policy.go b/internal/services/storage/parse/blob_inventory_policy.go deleted file mode 100644 index c006c79a8bb4..000000000000 --- a/internal/services/storage/parse/blob_inventory_policy.go +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -type BlobInventoryPolicyId struct { - SubscriptionId string - ResourceGroup string - StorageAccountName string - InventoryPolicyName string -} - -func NewBlobInventoryPolicyID(subscriptionId, resourceGroup, storageAccountName, inventoryPolicyName string) BlobInventoryPolicyId { - return BlobInventoryPolicyId{ - SubscriptionId: subscriptionId, - ResourceGroup: resourceGroup, - StorageAccountName: storageAccountName, - InventoryPolicyName: inventoryPolicyName, - } -} - -func (id BlobInventoryPolicyId) String() string { - segments := []string{ - fmt.Sprintf("Inventory Policy Name %q", id.InventoryPolicyName), - fmt.Sprintf("Storage Account Name %q", id.StorageAccountName), - fmt.Sprintf("Resource Group %q", id.ResourceGroup), - } - segmentsStr := strings.Join(segments, " / ") - return fmt.Sprintf("%s: (%s)", "Blob Inventory Policy", segmentsStr) -} - -func (id BlobInventoryPolicyId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Storage/storageAccounts/%s/inventoryPolicies/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.StorageAccountName, id.InventoryPolicyName) -} - -// BlobInventoryPolicyID parses a BlobInventoryPolicy ID into an BlobInventoryPolicyId struct -func BlobInventoryPolicyID(input string) (*BlobInventoryPolicyId, error) { - id, err := resourceids.ParseAzureResourceID(input) - if err != nil { - return nil, fmt.Errorf("parsing %q as an BlobInventoryPolicy ID: %+v", input, err) - } - - resourceId := BlobInventoryPolicyId{ - SubscriptionId: id.SubscriptionID, - ResourceGroup: id.ResourceGroup, - } - - if resourceId.SubscriptionId == "" { - return nil, fmt.Errorf("ID was missing the 'subscriptions' element") - } - - if resourceId.ResourceGroup == "" { - return nil, fmt.Errorf("ID was missing the 'resourceGroups' element") - } - - if resourceId.StorageAccountName, err = id.PopSegment("storageAccounts"); err != nil { - return nil, err - } - if resourceId.InventoryPolicyName, err = id.PopSegment("inventoryPolicies"); err != nil { - return nil, err - } - - if err := id.ValidateNoEmptySegments(input); err != nil { - return nil, err - } - - return &resourceId, nil -} diff --git a/internal/services/storage/parse/blob_inventory_policy_test.go b/internal/services/storage/parse/blob_inventory_policy_test.go deleted file mode 100644 index 186510a96205..000000000000 --- a/internal/services/storage/parse/blob_inventory_policy_test.go +++ /dev/null @@ -1,131 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.Id = BlobInventoryPolicyId{} - -func TestBlobInventoryPolicyIDFormatter(t *testing.T) { - actual := NewBlobInventoryPolicyID("12345678-1234-9876-4563-123456789012", "resGroup1", "storageAccount1", "inventoryPolicy1").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Storage/storageAccounts/storageAccount1/inventoryPolicies/inventoryPolicy1" - if actual != expected { - t.Fatalf("Expected %q but got %q", expected, actual) - } -} - -func TestBlobInventoryPolicyID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *BlobInventoryPolicyId - }{ - - { - // empty - Input: "", - Error: true, - }, - - { - // missing SubscriptionId - Input: "/", - Error: true, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Error: true, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Error: true, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Error: true, - }, - - { - // missing StorageAccountName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Storage/", - Error: true, - }, - - { - // missing value for StorageAccountName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Storage/storageAccounts/", - Error: true, - }, - - { - // missing InventoryPolicyName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Storage/storageAccounts/storageAccount1/", - Error: true, - }, - - { - // missing value for InventoryPolicyName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Storage/storageAccounts/storageAccount1/inventoryPolicies/", - Error: true, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Storage/storageAccounts/storageAccount1/inventoryPolicies/inventoryPolicy1", - Expected: &BlobInventoryPolicyId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resGroup1", - StorageAccountName: "storageAccount1", - InventoryPolicyName: "inventoryPolicy1", - }, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.STORAGE/STORAGEACCOUNTS/STORAGEACCOUNT1/INVENTORYPOLICIES/INVENTORYPOLICY1", - Error: true, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := BlobInventoryPolicyID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %s", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - if actual.ResourceGroup != v.Expected.ResourceGroup { - t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) - } - if actual.StorageAccountName != v.Expected.StorageAccountName { - t.Fatalf("Expected %q but got %q for StorageAccountName", v.Expected.StorageAccountName, actual.StorageAccountName) - } - if actual.InventoryPolicyName != v.Expected.InventoryPolicyName { - t.Fatalf("Expected %q but got %q for InventoryPolicyName", v.Expected.InventoryPolicyName, actual.InventoryPolicyName) - } - } -} diff --git a/internal/services/storage/resourceids.go b/internal/services/storage/resourceids.go index 003c70183894..140efc6913da 100644 --- a/internal/services/storage/resourceids.go +++ b/internal/services/storage/resourceids.go @@ -3,7 +3,6 @@ package storage -//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=BlobInventoryPolicy -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Storage/storageAccounts/storageAccount1/inventoryPolicies/inventoryPolicy1 //go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=StorageAccountDefaultBlob -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Storage/storageAccounts/storageAccount1/blobServices/default //go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=StorageQueueResourceManager -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Storage/storageAccounts/storageAccount1/queueServices/default/queues/queue1 //go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=StorageShareResourceManager -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Storage/storageAccounts/storageAccount1/fileServices/fileService1/fileshares/share1 diff --git a/internal/services/storage/storage_blob_inventory_policy_resource.go b/internal/services/storage/storage_blob_inventory_policy_resource.go index 9bcd3e41ef1a..4a51e20d24a0 100644 --- a/internal/services/storage/storage_blob_inventory_policy_resource.go +++ b/internal/services/storage/storage_blob_inventory_policy_resource.go @@ -9,11 +9,13 @@ import ( "log" "time" - "github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2021-09-01/storage" // nolint: staticcheck + "github.com/hashicorp/go-azure-helpers/lang/response" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" + "github.com/hashicorp/go-azure-sdk/resource-manager/storage/2023-01-01/blobinventorypolicies" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/storage/parse" + "github.com/hashicorp/terraform-provider-azurerm/internal/services/storage/migration" "github.com/hashicorp/terraform-provider-azurerm/internal/services/storage/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" @@ -36,141 +38,126 @@ func resourceStorageBlobInventoryPolicy() *pluginsdk.Resource { }, Importer: pluginsdk.ImporterValidatingResourceId(func(id string) error { - _, err := parse.BlobInventoryPolicyID(id) + _, err := commonids.ParseStorageAccountID(id) return err }), - Schema: storageBlobInventoryPolicyResourceSchema(), - CustomizeDiff: pluginsdk.CustomizeDiffShim(func(ctx context.Context, diff *pluginsdk.ResourceDiff, v interface{}) error { - rules := diff.Get("rules").(*pluginsdk.Set).List() - for _, rule := range rules { - v := rule.(map[string]interface{}) - if v["scope"] != string(storage.ObjectTypeBlob) && len(v["filter"].([]interface{})) != 0 { - return fmt.Errorf("the `filter` can only be set when the `scope` is `%s`", storage.ObjectTypeBlob) - } - } - - return nil + SchemaVersion: 1, + StateUpgraders: pluginsdk.StateUpgrades(map[int]pluginsdk.StateUpgrade{ + 0: migration.BlobInventoryPolicyV0ToV1{}, }), - } -} -func storageBlobInventoryPolicyResourceSchema() map[string]*pluginsdk.Schema { - return map[string]*pluginsdk.Schema{ - "storage_account_id": { - Type: pluginsdk.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: commonids.ValidateStorageAccountID, - }, + Schema: map[string]*pluginsdk.Schema{ + "storage_account_id": commonschema.ResourceIDReferenceRequiredForceNew(&commonids.StorageAccountId{}), - "rules": { - Type: pluginsdk.TypeSet, - Required: true, - Elem: &pluginsdk.Resource{ - Schema: map[string]*pluginsdk.Schema{ - "name": { - Type: pluginsdk.TypeString, - Required: true, - ValidateFunc: validation.StringIsNotEmpty, - }, + "rules": { + Type: pluginsdk.TypeSet, + Required: true, + Elem: &pluginsdk.Resource{ + Schema: map[string]*pluginsdk.Schema{ + "name": { + Type: pluginsdk.TypeString, + Required: true, + ValidateFunc: validation.StringIsNotEmpty, + }, - "storage_container_name": { - Type: pluginsdk.TypeString, - Required: true, - ValidateFunc: validate.StorageContainerName, - }, + "storage_container_name": { + Type: pluginsdk.TypeString, + Required: true, + ValidateFunc: validate.StorageContainerName, + }, - "format": { - Type: pluginsdk.TypeString, - Required: true, - ValidateFunc: validation.StringInSlice([]string{ - string(storage.FormatCsv), - string(storage.FormatParquet), - }, false), - }, + "format": { + Type: pluginsdk.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice([]string{ + string(blobinventorypolicies.FormatCsv), + string(blobinventorypolicies.FormatParquet), + }, false), + }, - "schedule": { - Type: pluginsdk.TypeString, - Required: true, - ValidateFunc: validation.StringInSlice([]string{ - string(storage.ScheduleDaily), - string(storage.ScheduleWeekly), - }, false), - }, + "schedule": { + Type: pluginsdk.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice([]string{ + string(blobinventorypolicies.ScheduleDaily), + string(blobinventorypolicies.ScheduleWeekly), + }, false), + }, - "scope": { - Type: pluginsdk.TypeString, - Required: true, - ValidateFunc: validation.StringInSlice([]string{ - string(storage.ObjectTypeBlob), - string(storage.ObjectTypeContainer), - }, false), - }, + "scope": { + Type: pluginsdk.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice([]string{ + string(blobinventorypolicies.ObjectTypeBlob), + string(blobinventorypolicies.ObjectTypeContainer), + }, false), + }, - "schema_fields": { - Type: pluginsdk.TypeList, - Required: true, - Elem: &pluginsdk.Schema{ - Type: pluginsdk.TypeString, - ValidateFunc: validation.StringIsNotEmpty, + "schema_fields": { + Type: pluginsdk.TypeList, + Required: true, + Elem: &pluginsdk.Schema{ + Type: pluginsdk.TypeString, + ValidateFunc: validation.StringIsNotEmpty, + }, }, - }, - "filter": { - Type: pluginsdk.TypeList, - Optional: true, - MaxItems: 1, - Elem: &pluginsdk.Resource{ - Schema: map[string]*pluginsdk.Schema{ - "blob_types": { - Type: pluginsdk.TypeSet, - Required: true, - Elem: &pluginsdk.Schema{ - Type: pluginsdk.TypeString, - ValidateFunc: validation.StringInSlice([]string{ - "blockBlob", - "appendBlob", - "pageBlob", - }, false), + "filter": { + Type: pluginsdk.TypeList, + Optional: true, + MaxItems: 1, + Elem: &pluginsdk.Resource{ + Schema: map[string]*pluginsdk.Schema{ + "blob_types": { + Type: pluginsdk.TypeSet, + Required: true, + Elem: &pluginsdk.Schema{ + Type: pluginsdk.TypeString, + ValidateFunc: validation.StringInSlice([]string{ + "blockBlob", + "appendBlob", + "pageBlob", + }, false), + }, }, - }, - "include_blob_versions": { - Type: pluginsdk.TypeBool, - Optional: true, - Default: false, - }, + "include_blob_versions": { + Type: pluginsdk.TypeBool, + Optional: true, + Default: false, + }, - "include_deleted": { - Type: pluginsdk.TypeBool, - Optional: true, - Default: false, - }, + "include_deleted": { + Type: pluginsdk.TypeBool, + Optional: true, + Default: false, + }, - "include_snapshots": { - Type: pluginsdk.TypeBool, - Optional: true, - Default: false, - }, + "include_snapshots": { + Type: pluginsdk.TypeBool, + Optional: true, + Default: false, + }, - "prefix_match": { - Type: pluginsdk.TypeSet, - Optional: true, - MaxItems: 10, - Elem: &pluginsdk.Schema{ - Type: pluginsdk.TypeString, - ValidateFunc: validation.StringIsNotEmpty, + "prefix_match": { + Type: pluginsdk.TypeSet, + Optional: true, + MaxItems: 10, + Elem: &pluginsdk.Schema{ + Type: pluginsdk.TypeString, + ValidateFunc: validation.StringIsNotEmpty, + }, }, - }, - "exclude_prefixes": { - Type: pluginsdk.TypeSet, - Optional: true, - MaxItems: 10, - Elem: &pluginsdk.Schema{ - Type: pluginsdk.TypeString, - ValidateFunc: validation.StringIsNotEmpty, + "exclude_prefixes": { + Type: pluginsdk.TypeSet, + Optional: true, + MaxItems: 10, + Elem: &pluginsdk.Schema{ + Type: pluginsdk.TypeString, + ValidateFunc: validation.StringIsNotEmpty, + }, }, }, }, @@ -179,44 +166,57 @@ func storageBlobInventoryPolicyResourceSchema() map[string]*pluginsdk.Schema { }, }, }, + + CustomizeDiff: pluginsdk.CustomizeDiffShim(func(ctx context.Context, diff *pluginsdk.ResourceDiff, v interface{}) error { + rules := diff.Get("rules").(*pluginsdk.Set).List() + for _, rule := range rules { + v := rule.(map[string]interface{}) + if v["scope"] != string(blobinventorypolicies.ObjectTypeBlob) && len(v["filter"].([]interface{})) != 0 { + return fmt.Errorf("the `filter` can only be set when the `scope` is `%s`", blobinventorypolicies.ObjectTypeBlob) + } + } + + return nil + }), } } func resourceStorageBlobInventoryPolicyCreateUpdate(d *pluginsdk.ResourceData, meta interface{}) error { subscriptionId := meta.(*clients.Client).Account.SubscriptionId - client := meta.(*clients.Client).Storage.BlobInventoryPoliciesClient + client := meta.(*clients.Client).Storage.ResourceManager.BlobInventoryPolicies ctx, cancel := timeouts.ForCreateUpdate(meta.(*clients.Client).StopContext, d) defer cancel() - storageAccount, err := commonids.ParseStorageAccountID(d.Get("storage_account_id").(string)) + accountId, err := commonids.ParseStorageAccountID(d.Get("storage_account_id").(string)) if err != nil { return err } - id := parse.NewBlobInventoryPolicyID(subscriptionId, storageAccount.ResourceGroupName, storageAccount.StorageAccountName, "Default") - + // This Resource is 1:1 with a Storage Account, therefore we use it's Resource ID for this Resource + // however we want to ensure it's in the same subscription, so we'll build this up here + id := commonids.NewStorageAccountID(subscriptionId, accountId.ResourceGroupName, accountId.StorageAccountName) if d.IsNewResource() { - existing, err := client.Get(ctx, id.ResourceGroup, id.StorageAccountName) + existing, err := client.Get(ctx, id) if err != nil { - if !utils.ResponseWasNotFound(existing.Response) { + if !response.WasNotFound(existing.HttpResponse) { return fmt.Errorf("checking for existing %q: %+v", id, err) } } - if !utils.ResponseWasNotFound(existing.Response) { + if !response.WasNotFound(existing.HttpResponse) { return tf.ImportAsExistsError("azurerm_storage_blob_inventory_policy", id.ID()) } } - props := storage.BlobInventoryPolicy{ - BlobInventoryPolicyProperties: &storage.BlobInventoryPolicyProperties{ - Policy: &storage.BlobInventoryPolicySchema{ - Enabled: utils.Bool(true), - Type: utils.String("Inventory"), + payload := blobinventorypolicies.BlobInventoryPolicy{ + Properties: &blobinventorypolicies.BlobInventoryPolicyProperties{ + Policy: blobinventorypolicies.BlobInventoryPolicySchema{ + Enabled: true, + Type: blobinventorypolicies.InventoryRuleTypeInventory, Rules: expandBlobInventoryPolicyRules(d.Get("rules").(*pluginsdk.Set).List()), }, }, } - if _, err := client.CreateOrUpdate(ctx, id.ResourceGroup, id.StorageAccountName, props); err != nil { + if _, err := client.CreateOrUpdate(ctx, id, payload); err != nil { return fmt.Errorf("creating/updating %q: %+v", id, err) } @@ -225,82 +225,83 @@ func resourceStorageBlobInventoryPolicyCreateUpdate(d *pluginsdk.ResourceData, m } func resourceStorageBlobInventoryPolicyRead(d *pluginsdk.ResourceData, meta interface{}) error { - subscriptionId := meta.(*clients.Client).Account.SubscriptionId - client := meta.(*clients.Client).Storage.BlobInventoryPoliciesClient + client := meta.(*clients.Client).Storage.ResourceManager.BlobInventoryPolicies ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.BlobInventoryPolicyID(d.Id()) + id, err := commonids.ParseStorageAccountID(d.Id()) if err != nil { return err } - resp, err := client.Get(ctx, id.ResourceGroup, id.StorageAccountName) + resp, err := client.Get(ctx, *id) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { - log.Printf("[INFO] storage %q does not exist - removing from state", d.Id()) + if response.WasNotFound(resp.HttpResponse) { + log.Printf("[INFO] Blob Inventory Policy for %s was not found - removing from state", *id) d.SetId("") return nil } return fmt.Errorf("retrieving %q: %+v", id, err) } - d.Set("storage_account_id", commonids.NewStorageAccountID(subscriptionId, id.ResourceGroup, id.StorageAccountName).ID()) - if props := resp.BlobInventoryPolicyProperties; props != nil { - if policy := props.Policy; policy != nil { - if policy.Enabled == nil || !*policy.Enabled { - log.Printf("[INFO] storage %q is not enabled - removing from state", d.Id()) + + if model := resp.Model; model != nil { + d.Set("storage_account_id", id.ID()) + if props := model.Properties; props != nil { + if !props.Policy.Enabled { + log.Printf("[INFO] Blob Inventory Policy is not enabled for %s - removing from state", *id) d.SetId("") return nil } - d.Set("rules", flattenBlobInventoryPolicyRules(policy.Rules)) + d.Set("rules", flattenBlobInventoryPolicyRules(props.Policy.Rules)) } } + return nil } func resourceStorageBlobInventoryPolicyDelete(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Storage.BlobInventoryPoliciesClient + client := meta.(*clients.Client).Storage.ResourceManager.BlobInventoryPolicies ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.BlobInventoryPolicyID(d.Id()) + id, err := commonids.ParseStorageAccountID(d.Id()) if err != nil { return err } - if _, err := client.Delete(ctx, id.ResourceGroup, id.StorageAccountName); err != nil { + if _, err := client.Delete(ctx, *id); err != nil { return fmt.Errorf("deleting %q: %+v", id, err) } return nil } -func expandBlobInventoryPolicyRules(input []interface{}) *[]storage.BlobInventoryPolicyRule { - results := make([]storage.BlobInventoryPolicyRule, 0) +func expandBlobInventoryPolicyRules(input []interface{}) []blobinventorypolicies.BlobInventoryPolicyRule { + results := make([]blobinventorypolicies.BlobInventoryPolicyRule, 0) for _, item := range input { v := item.(map[string]interface{}) - results = append(results, storage.BlobInventoryPolicyRule{ - Enabled: utils.Bool(true), - Name: utils.String(v["name"].(string)), - Destination: utils.String(v["storage_container_name"].(string)), - Definition: &storage.BlobInventoryPolicyDefinition{ - Format: storage.Format(v["format"].(string)), - Schedule: storage.Schedule(v["schedule"].(string)), - ObjectType: storage.ObjectType(v["scope"].(string)), - SchemaFields: utils.ExpandStringSlice(v["schema_fields"].([]interface{})), + results = append(results, blobinventorypolicies.BlobInventoryPolicyRule{ + Enabled: true, + Name: v["name"].(string), + Destination: v["storage_container_name"].(string), + Definition: blobinventorypolicies.BlobInventoryPolicyDefinition{ + Format: blobinventorypolicies.Format(v["format"].(string)), + Schedule: blobinventorypolicies.Schedule(v["schedule"].(string)), + ObjectType: blobinventorypolicies.ObjectType(v["scope"].(string)), + SchemaFields: *utils.ExpandStringSlice(v["schema_fields"].([]interface{})), Filters: expandBlobInventoryPolicyFilter(v["filter"].([]interface{})), }, }) } - return &results + return results } -func expandBlobInventoryPolicyFilter(input []interface{}) *storage.BlobInventoryPolicyFilter { +func expandBlobInventoryPolicyFilter(input []interface{}) *blobinventorypolicies.BlobInventoryPolicyFilter { if len(input) == 0 { return nil } v := input[0].(map[string]interface{}) - return &storage.BlobInventoryPolicyFilter{ + return &blobinventorypolicies.BlobInventoryPolicyFilter{ PrefixMatch: utils.ExpandStringSlice(v["prefix_match"].(*pluginsdk.Set).List()), ExcludePrefix: utils.ExpandStringSlice(v["exclude_prefixes"].(*pluginsdk.Set).List()), BlobTypes: utils.ExpandStringSlice(v["blob_types"].(*pluginsdk.Set).List()), @@ -310,41 +311,31 @@ func expandBlobInventoryPolicyFilter(input []interface{}) *storage.BlobInventory } } -func flattenBlobInventoryPolicyRules(input *[]storage.BlobInventoryPolicyRule) []interface{} { +func flattenBlobInventoryPolicyRules(input []blobinventorypolicies.BlobInventoryPolicyRule) []interface{} { results := make([]interface{}, 0) if input == nil { return results } - for _, item := range *input { - var name string - if item.Name != nil { - name = *item.Name - } - - var destination string - if item.Destination != nil { - destination = *item.Destination - } - - if item.Enabled == nil || !*item.Enabled || item.Definition == nil { + for _, item := range input { + if !item.Enabled { continue } results = append(results, map[string]interface{}{ - "name": name, - "storage_container_name": destination, + "name": item.Name, + "storage_container_name": item.Destination, "format": string(item.Definition.Format), "schedule": string(item.Definition.Schedule), "scope": string(item.Definition.ObjectType), - "schema_fields": utils.FlattenStringSlice(item.Definition.SchemaFields), + "schema_fields": item.Definition.SchemaFields, "filter": flattenBlobInventoryPolicyFilter(item.Definition.Filters), }) } return results } -func flattenBlobInventoryPolicyFilter(input *storage.BlobInventoryPolicyFilter) []interface{} { +func flattenBlobInventoryPolicyFilter(input *blobinventorypolicies.BlobInventoryPolicyFilter) []interface{} { if input == nil { return make([]interface{}, 0) } diff --git a/internal/services/storage/storage_blob_inventory_policy_resource_test.go b/internal/services/storage/storage_blob_inventory_policy_resource_test.go index ff7f21a0b3fa..72290cd7badc 100644 --- a/internal/services/storage/storage_blob_inventory_policy_resource_test.go +++ b/internal/services/storage/storage_blob_inventory_policy_resource_test.go @@ -8,12 +8,13 @@ import ( "fmt" "testing" + "github.com/hashicorp/go-azure-helpers/lang/pointer" + "github.com/hashicorp/go-azure-helpers/lang/response" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/storage/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" - "github.com/hashicorp/terraform-provider-azurerm/utils" ) type StorageBlobInventoryPolicyResource struct{} @@ -96,25 +97,28 @@ func TestAccStorageBlobInventoryPolicy_update(t *testing.T) { } func (r StorageBlobInventoryPolicyResource) Exists(ctx context.Context, client *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { - id, err := parse.BlobInventoryPolicyID(state.ID) + id, err := commonids.ParseStorageAccountID(state.ID) if err != nil { return nil, err } - resp, err := client.Storage.BlobInventoryPoliciesClient.Get(ctx, id.ResourceGroup, id.StorageAccountName) + + resp, err := client.Storage.ResourceManager.BlobInventoryPolicies.Get(ctx, *id) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { - return utils.Bool(false), nil + if response.WasNotFound(resp.HttpResponse) { + return pointer.To(false), nil } - return nil, fmt.Errorf("retrieving %q: %+v", id, err) + return nil, fmt.Errorf("retrieving %s: %+v", *id, err) } - if props := resp.BlobInventoryPolicyProperties; props != nil { - if policy := props.Policy; policy != nil { - if policy.Enabled == nil || !*policy.Enabled { - return utils.Bool(false), nil + + found := false + if model := resp.Model; model != nil { + if props := model.Properties; props != nil { + if props.Policy.Enabled { + found = true } } } - return utils.Bool(true), nil + return pointer.To(found), nil } func (r StorageBlobInventoryPolicyResource) template(data acceptance.TestData) string { diff --git a/internal/services/storage/validate/blob_inventory_policy_id.go b/internal/services/storage/validate/blob_inventory_policy_id.go deleted file mode 100644 index fb5c5a62be45..000000000000 --- a/internal/services/storage/validate/blob_inventory_policy_id.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - - "github.com/hashicorp/terraform-provider-azurerm/internal/services/storage/parse" -) - -func BlobInventoryPolicyID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := parse.BlobInventoryPolicyID(v); err != nil { - errors = append(errors, err) - } - - return -} diff --git a/internal/services/storage/validate/blob_inventory_policy_id_test.go b/internal/services/storage/validate/blob_inventory_policy_id_test.go deleted file mode 100644 index 07bce34f1331..000000000000 --- a/internal/services/storage/validate/blob_inventory_policy_id_test.go +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import "testing" - -func TestBlobInventoryPolicyID(t *testing.T) { - cases := []struct { - Input string - Valid bool - }{ - - { - // empty - Input: "", - Valid: false, - }, - - { - // missing SubscriptionId - Input: "/", - Valid: false, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Valid: false, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Valid: false, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Valid: false, - }, - - { - // missing StorageAccountName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Storage/", - Valid: false, - }, - - { - // missing value for StorageAccountName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Storage/storageAccounts/", - Valid: false, - }, - - { - // missing InventoryPolicyName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Storage/storageAccounts/storageAccount1/", - Valid: false, - }, - - { - // missing value for InventoryPolicyName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Storage/storageAccounts/storageAccount1/inventoryPolicies/", - Valid: false, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Storage/storageAccounts/storageAccount1/inventoryPolicies/inventoryPolicy1", - Valid: true, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.STORAGE/STORAGEACCOUNTS/STORAGEACCOUNT1/INVENTORYPOLICIES/INVENTORYPOLICY1", - Valid: false, - }, - } - for _, tc := range cases { - t.Logf("[DEBUG] Testing Value %s", tc.Input) - _, errors := BlobInventoryPolicyID(tc.Input, "test") - valid := len(errors) == 0 - - if tc.Valid != valid { - t.Fatalf("Expected %t but got %t", tc.Valid, valid) - } - } -} From 721839d7575a99f563710a984c03ed66aaa54812 Mon Sep 17 00:00:00 2001 From: tombuildsstuff Date: Fri, 15 Mar 2024 11:59:33 +0100 Subject: [PATCH 3/4] storage: fixing the build --- internal/services/storage/storage_container_data_source.go | 6 +++++- internal/services/storage/storage_share_data_source.go | 7 ++++++- internal/services/storage/storage_share_resource.go | 7 ++++++- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/internal/services/storage/storage_container_data_source.go b/internal/services/storage/storage_container_data_source.go index 30e99688f495..7e37aad6bbb3 100644 --- a/internal/services/storage/storage_container_data_source.go +++ b/internal/services/storage/storage_container_data_source.go @@ -117,7 +117,11 @@ func dataSourceStorageContainerRead(d *pluginsdk.ResourceData, meta interface{}) d.Set("has_immutability_policy", props.HasImmutabilityPolicy) d.Set("has_legal_hold", props.HasLegalHold) - resourceManagerId := commonids.NewStorageContainerID(storageClient.SubscriptionId, account.ResourceGroup, accountName, containerName) + storageAccountId, err := commonids.ParseStorageAccountIDInsensitively(account.ID) + if err != nil { + return err + } + resourceManagerId := commonids.NewStorageContainerID(storageAccountId.SubscriptionId, storageAccountId.ResourceGroupName, storageAccountId.StorageAccountName, containerName) d.Set("resource_manager_id", resourceManagerId.ID()) return nil diff --git a/internal/services/storage/storage_share_data_source.go b/internal/services/storage/storage_share_data_source.go index 9faace9ed9ae..6975dd5d1fad 100644 --- a/internal/services/storage/storage_share_data_source.go +++ b/internal/services/storage/storage_share_data_source.go @@ -5,6 +5,7 @@ package storage import ( "fmt" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" "time" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" @@ -139,7 +140,11 @@ func dataSourceStorageShareRead(d *pluginsdk.ResourceData, meta interface{}) err return fmt.Errorf("setting `metadata`: %v", err) } - resourceManagerId := parse.NewStorageShareResourceManagerID(storageClient.SubscriptionId, account.ResourceGroup, accountName, "default", shareName) + storageAccountId, err := commonids.ParseStorageAccountIDInsensitively(account.ID) + if err != nil { + return err + } + resourceManagerId := parse.NewStorageShareResourceManagerID(storageAccountId.SubscriptionId, storageAccountId.ResourceGroupName, storageAccountId.StorageAccountName, "default", shareName) d.Set("resource_manager_id", resourceManagerId.ID()) return nil diff --git a/internal/services/storage/storage_share_resource.go b/internal/services/storage/storage_share_resource.go index 58b923dec4da..1f8350f4c2b7 100644 --- a/internal/services/storage/storage_share_resource.go +++ b/internal/services/storage/storage_share_resource.go @@ -5,6 +5,7 @@ package storage import ( "fmt" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" "log" "time" @@ -285,7 +286,11 @@ func resourceStorageShareRead(d *pluginsdk.ResourceData, meta interface{}) error return fmt.Errorf("flattening `metadata`: %+v", err) } - resourceManagerId := parse.NewStorageShareResourceManagerID(storageClient.SubscriptionId, account.ResourceGroup, id.AccountId.AccountName, "default", id.ShareName) + storageAccountId, err := commonids.ParseStorageAccountIDInsensitively(account.ID) + if err != nil { + return err + } + resourceManagerId := parse.NewStorageShareResourceManagerID(storageAccountId.SubscriptionId, storageAccountId.ResourceGroupName, storageAccountId.StorageAccountName, "default", id.ShareName) d.Set("resource_manager_id", resourceManagerId.ID()) return nil From bc7da115adfca408f4a50bdb1f8ec4325198eae0 Mon Sep 17 00:00:00 2001 From: tombuildsstuff Date: Fri, 15 Mar 2024 15:49:48 +0100 Subject: [PATCH 4/4] linting --- internal/services/storage/storage_share_data_source.go | 2 +- internal/services/storage/storage_share_resource.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/services/storage/storage_share_data_source.go b/internal/services/storage/storage_share_data_source.go index 6975dd5d1fad..f56e314e9982 100644 --- a/internal/services/storage/storage_share_data_source.go +++ b/internal/services/storage/storage_share_data_source.go @@ -5,9 +5,9 @@ package storage import ( "fmt" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" "time" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" "github.com/hashicorp/terraform-provider-azurerm/internal/services/storage/client" "github.com/hashicorp/terraform-provider-azurerm/internal/services/storage/parse" diff --git a/internal/services/storage/storage_share_resource.go b/internal/services/storage/storage_share_resource.go index 1f8350f4c2b7..624ed4df04a7 100644 --- a/internal/services/storage/storage_share_resource.go +++ b/internal/services/storage/storage_share_resource.go @@ -5,11 +5,11 @@ package storage import ( "fmt" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" "log" "time" "github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2021-09-01/storage" // nolint: staticcheck + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" "github.com/hashicorp/terraform-provider-azurerm/internal/services/storage/client"