Skip to content

Commit

Permalink
azurerm_managed_disk - remove old parse/validate and update state m…
Browse files Browse the repository at this point in the history
…igration
  • Loading branch information
myc2h6o committed Oct 26, 2022
1 parent 8cf2bd9 commit e5a6946
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 286 deletions.
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
12 changes: 8 additions & 4 deletions internal/services/compute/migration/managed_disk_v0_to_v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package migration

import (
"context"
"log"

"github.com/hashicorp/go-azure-sdk/resource-manager/compute/2022-03-02/disks"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
Expand All @@ -15,12 +16,15 @@ type ManagedDiskV0ToV1 struct{}

func (ManagedDiskV0ToV1) UpgradeFunc() pluginsdk.StateUpgraderFunc {
return func(ctx context.Context, rawState map[string]interface{}, meta interface{}) (map[string]interface{}, error) {
oldId, err := disks.ParseDiskIDInsensitively(rawState["id"].(string))
oldIdRaw := rawState["id"].(string)
oldId, err := disks.ParseDiskIDInsensitively(oldIdRaw)
if err != nil {
return rawState, err
}

rawState["id"] = oldId.ID()
newId := oldId.ID()
log.Printf("[DEBUG] Updating the ID from %q to %q", oldIdRaw, newId)
rawState["id"] = newId
return rawState, nil
}
}
Expand Down Expand Up @@ -129,7 +133,7 @@ func (ManagedDiskV0ToV1) Schema() map[string]*pluginsdk.Schema {
Optional: true,
},

"encryption_settings": encryptionSettingsSchema(),
"encryption_settings": managedDiskEncryptionSettingsSchemaV0(),

"network_access_policy": {
Type: pluginsdk.TypeString,
Expand Down Expand Up @@ -197,7 +201,7 @@ func (ManagedDiskV0ToV1) Schema() map[string]*pluginsdk.Schema {
}
}

func encryptionSettingsSchema() *pluginsdk.Schema {
func managedDiskEncryptionSettingsSchemaV0() *pluginsdk.Schema {
if !features.FourPointOhBeta() {
return &pluginsdk.Schema{
Type: pluginsdk.TypeList,
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.

0 comments on commit e5a6946

Please sign in to comment.