Skip to content

Commit

Permalink
azurerm_managed_disk - remove old parse/validate
Browse files Browse the repository at this point in the history
  • Loading branch information
myc2h6o committed Oct 26, 2022
1 parent 8cf2bd9 commit 9b3ef24
Show file tree
Hide file tree
Showing 16 changed files with 45 additions and 328 deletions.
6 changes: 2 additions & 4 deletions internal/services/compute/disk_sas_token_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import (

"github.com/hashicorp/go-azure-sdk/resource-manager/compute/2022-03-02/disks"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/compute/parse"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/compute/validate"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation"
"github.com/hashicorp/terraform-provider-azurerm/internal/timeouts"
Expand Down Expand Up @@ -42,7 +40,7 @@ func resourceManagedDiskSasToken() *pluginsdk.Resource {
},

Importer: pluginsdk.ImporterValidatingResourceId(func(id string) error {
_, err := parse.ManagedDiskID(id)
_, err := disks.ParseDiskID(id)
return err
}),

Expand All @@ -51,7 +49,7 @@ func resourceManagedDiskSasToken() *pluginsdk.Resource {
Type: pluginsdk.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: validate.ManagedDiskID,
ValidateFunc: disks.ValidateDiskID,
},

// unable to provide upper value of 4294967295 as it's not comptabile with 32-bit (overflow errors)
Expand Down
2 changes: 1 addition & 1 deletion internal/services/compute/managed_disk_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func resourceManagedDisk() *pluginsdk.Resource {
}),

Importer: pluginsdk.ImporterValidatingResourceId(func(id string) error {
_, err := parse.ManagedDiskID(id)
_, err := disks.ParseDiskID(id)
return err
}),

Expand Down
69 changes: 0 additions & 69 deletions internal/services/compute/parse/managed_disk.go

This file was deleted.

112 changes: 0 additions & 112 deletions internal/services/compute/parse/managed_disk_test.go

This file was deleted.

1 change: 0 additions & 1 deletion internal/services/compute/resourceids.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package compute
//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=GalleryApplication -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Compute/galleries/gallery1/applications/galleryApplication1
//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=GalleryApplicationVersion -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Compute/galleries/gallery1/applications/galleryApplication1/versions/galleryApplicationVersion1
//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=Image -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Compute/images/image1
//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=ManagedDisk -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Compute/disks/disk1
//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=SharedImage -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Compute/galleries/gallery1/images/image1
//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=SharedImageGallery -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Compute/galleries/gallery1
//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=SharedImageVersion -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Compute/galleries/gallery1/images/image1/versions/version1
Expand Down
23 changes: 0 additions & 23 deletions internal/services/compute/validate/managed_disk_id.go

This file was deleted.

76 changes: 0 additions & 76 deletions internal/services/compute/validate/managed_disk_id_test.go

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@ import (
"github.com/hashicorp/go-azure-helpers/lang/response"
"github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema"
"github.com/hashicorp/go-azure-helpers/resourcemanager/location"
"github.com/hashicorp/go-azure-sdk/resource-manager/compute/2022-03-02/disks"
"github.com/hashicorp/go-azure-sdk/resource-manager/dataprotection/2022-04-01/backupinstances"
"github.com/hashicorp/go-azure-sdk/resource-manager/dataprotection/2022-04-01/backuppolicies"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-provider-azurerm/helpers/tf"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
computeParse "github.com/hashicorp/terraform-provider-azurerm/internal/services/compute/parse"
computeValidate "github.com/hashicorp/terraform-provider-azurerm/internal/services/compute/validate"
resourceParse "github.com/hashicorp/terraform-provider-azurerm/internal/services/resource/parse"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk"
azSchema "github.com/hashicorp/terraform-provider-azurerm/internal/tf/schema"
Expand Down Expand Up @@ -61,7 +60,7 @@ func resourceDataProtectionBackupInstanceDisk() *schema.Resource {
Type: schema.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: computeValidate.ManagedDiskID,
ValidateFunc: disks.ValidateDiskID,
},

"snapshot_resource_group_name": commonschema.ResourceGroupName(),
Expand Down Expand Up @@ -97,7 +96,7 @@ func resourceDataProtectionBackupInstanceDiskCreateUpdate(d *schema.ResourceData
}
}

diskId, _ := computeParse.ManagedDiskID(d.Get("disk_id").(string))
diskId, _ := disks.ParseDiskID(d.Get("disk_id").(string))
location := location.Normalize(d.Get("location").(string))
policyId, _ := backuppolicies.ParseBackupPolicyID(d.Get("backup_policy_id").(string))
snapshotResourceGroupId := resourceParse.NewResourceGroupID(subscriptionId, d.Get("snapshot_resource_group_name").(string))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ import (
"time"

"github.com/hashicorp/go-azure-helpers/lang/response"
"github.com/hashicorp/go-azure-sdk/resource-manager/compute/2022-03-02/disks"
"github.com/hashicorp/go-azure-sdk/resource-manager/storagepool/2021-08-01/diskpools"
"github.com/hashicorp/go-azure-sdk/resource-manager/storagepool/2021-08-01/iscsitargets"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-provider-azurerm/internal/locks"
"github.com/hashicorp/terraform-provider-azurerm/internal/sdk"
computeParse "github.com/hashicorp/terraform-provider-azurerm/internal/services/compute/parse"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/disks/parse"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/disks/validate"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk"
Expand Down Expand Up @@ -176,7 +176,7 @@ func (d DiskPoolIscsiTargetLunModel) Read() sdk.ResourceFunc {
for _, lun := range *resp.Model.Properties.Luns {
if lun.ManagedDiskAzureResourceId == id.ManagedDiskId.ID() {
diskPoolId := diskpools.NewDiskPoolID(iscsiTargetId.SubscriptionId, iscsiTargetId.ResourceGroupName, iscsiTargetId.DiskPoolName)
diskId, err := computeParse.ManagedDiskID(lun.ManagedDiskAzureResourceId)
diskId, err := disks.ParseDiskID(lun.ManagedDiskAzureResourceId)
if err != nil {
return fmt.Errorf("invalid managed disk id in iscsi target response %q : %q", iscsiTargetId.ID(), lun.ManagedDiskAzureResourceId)
}
Expand Down
Loading

0 comments on commit 9b3ef24

Please sign in to comment.