diff --git a/internal/services/compute/gallery_application_resource.go b/internal/services/compute/gallery_application_resource.go index 424e7f3b7f04..15975ebb58b5 100644 --- a/internal/services/compute/gallery_application_resource.go +++ b/internal/services/compute/gallery_application_resource.go @@ -10,9 +10,9 @@ import ( "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/go-azure-helpers/resourcemanager/commonschema" "github.com/hashicorp/go-azure-helpers/resourcemanager/location" - "github.com/hashicorp/go-azure-sdk/resource-manager/compute/2022-03-03/galleries" "github.com/hashicorp/go-azure-sdk/resource-manager/compute/2022-03-03/galleryapplications" "github.com/hashicorp/terraform-provider-azurerm/internal/sdk" "github.com/hashicorp/terraform-provider-azurerm/internal/services/compute/validate" @@ -55,7 +55,7 @@ func (r GalleryApplicationResource) Arguments() map[string]*pluginsdk.Schema { Type: pluginsdk.TypeString, Required: true, ForceNew: true, - ValidateFunc: galleries.ValidateGalleryID, + ValidateFunc: commonids.ValidateSharedImageGalleryID, }, "location": commonschema.Location(), @@ -128,7 +128,7 @@ func (r GalleryApplicationResource) Create() sdk.ResourceFunc { client := metadata.Client.Compute.GalleryApplicationsClient subscriptionId := metadata.Client.Account.SubscriptionId - galleryId, err := galleries.ParseGalleryID(state.GalleryId) + galleryId, err := commonids.ParseSharedImageGalleryID(state.GalleryId) if err != nil { return err } @@ -203,7 +203,7 @@ func (r GalleryApplicationResource) Read() sdk.ResourceFunc { state := &GalleryApplicationModel{ Name: id.ApplicationName, - GalleryId: galleries.NewGalleryID(id.SubscriptionId, id.ResourceGroupName, id.GalleryName).ID(), + GalleryId: commonids.NewSharedImageGalleryID(id.SubscriptionId, id.ResourceGroupName, id.GalleryName).ID(), } if model := resp.Model; model != nil { diff --git a/internal/services/compute/shared_image_gallery_data_source.go b/internal/services/compute/shared_image_gallery_data_source.go index 2a6cf59d7c06..005d16a450e9 100644 --- a/internal/services/compute/shared_image_gallery_data_source.go +++ b/internal/services/compute/shared_image_gallery_data_source.go @@ -8,6 +8,7 @@ import ( "time" "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-helpers/resourcemanager/location" "github.com/hashicorp/go-azure-helpers/resourcemanager/tags" @@ -58,7 +59,7 @@ func dataSourceSharedImageGalleryRead(d *pluginsdk.ResourceData, meta interface{ ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() - id := galleries.NewGalleryID(subscriptionId, d.Get("resource_group_name").(string), d.Get("name").(string)) + id := commonids.NewSharedImageGalleryID(subscriptionId, d.Get("resource_group_name").(string), d.Get("name").(string)) resp, err := client.Get(ctx, id, galleries.DefaultGetOperationOptions()) if err != nil { if response.WasNotFound(resp.HttpResponse) { diff --git a/internal/services/compute/shared_image_gallery_resource.go b/internal/services/compute/shared_image_gallery_resource.go index b2b5308d2f3e..1c7dad294bbc 100644 --- a/internal/services/compute/shared_image_gallery_resource.go +++ b/internal/services/compute/shared_image_gallery_resource.go @@ -10,6 +10,7 @@ import ( "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/go-azure-helpers/resourcemanager/commonschema" "github.com/hashicorp/go-azure-helpers/resourcemanager/location" "github.com/hashicorp/go-azure-helpers/resourcemanager/tags" @@ -30,7 +31,7 @@ func resourceSharedImageGallery() *pluginsdk.Resource { Update: resourceSharedImageGalleryUpdate, Delete: resourceSharedImageGalleryDelete, Importer: pluginsdk.ImporterValidatingResourceId(func(id string) error { - _, err := galleries.ParseGalleryID(id) + _, err := commonids.ParseSharedImageGalleryID(id) return err }), @@ -135,7 +136,7 @@ func resourceSharedImageGalleryCreate(d *pluginsdk.ResourceData, meta interface{ ctx, cancel := timeouts.ForCreate(meta.(*clients.Client).StopContext, d) defer cancel() - id := galleries.NewGalleryID(subscriptionId, d.Get("resource_group_name").(string), d.Get("name").(string)) + id := commonids.NewSharedImageGalleryID(subscriptionId, d.Get("resource_group_name").(string), d.Get("name").(string)) existing, err := client.Get(ctx, id, galleries.DefaultGetOperationOptions()) if err != nil { if !response.WasNotFound(existing.HttpResponse) { @@ -166,8 +167,10 @@ func resourceSharedImageGalleryCreate(d *pluginsdk.ResourceData, meta interface{ } if permission == galleries.GallerySharingPermissionTypesCommunity { - gallerySharingUpdateId := gallerysharingupdate.NewGalleryID(id.SubscriptionId, id.ResourceGroupName, id.GalleryName) - if err = gallerySharingUpdateClient.GallerySharingProfileUpdateThenPoll(ctx, gallerySharingUpdateId, gallerysharingupdate.SharingUpdate{OperationType: gallerysharingupdate.SharingUpdateOperationTypesEnableCommunity}); err != nil { + updatePayload := gallerysharingupdate.SharingUpdate{ + OperationType: gallerysharingupdate.SharingUpdateOperationTypesEnableCommunity, + } + if err = gallerySharingUpdateClient.GallerySharingProfileUpdateThenPoll(ctx, id, updatePayload); err != nil { return fmt.Errorf("enabling community sharing of %s: %+v", id, err) } } @@ -182,7 +185,7 @@ func resourceSharedImageGalleryRead(d *pluginsdk.ResourceData, meta interface{}) ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := galleries.ParseGalleryID(d.Id()) + id, err := commonids.ParseSharedImageGalleryID(d.Id()) if err != nil { return err } @@ -229,7 +232,7 @@ func resourceSharedImageGalleryUpdate(d *pluginsdk.ResourceData, meta interface{ ctx, cancel := timeouts.ForUpdate(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := galleries.ParseGalleryID(d.Id()) + id, err := commonids.ParseSharedImageGalleryID(d.Id()) if err != nil { return err } @@ -268,7 +271,7 @@ func resourceSharedImageGalleryDelete(d *pluginsdk.ResourceData, meta interface{ ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := galleries.ParseGalleryID(d.Id()) + id, err := commonids.ParseSharedImageGalleryID(d.Id()) if err != nil { return err } @@ -281,8 +284,10 @@ func resourceSharedImageGalleryDelete(d *pluginsdk.ResourceData, meta interface{ if model := resp.Model; model != nil { if prop := model.Properties; prop != nil && prop.SharingProfile != nil && prop.SharingProfile.Permissions != nil { if pointer.From(prop.SharingProfile.Permissions) == galleries.GallerySharingPermissionTypesCommunity { - gallerySharingUpdateId := gallerysharingupdate.NewGalleryID(id.SubscriptionId, id.ResourceGroupName, id.GalleryName) - if err = gallerySharingUpdateClient.GallerySharingProfileUpdateThenPoll(ctx, gallerySharingUpdateId, gallerysharingupdate.SharingUpdate{OperationType: gallerysharingupdate.SharingUpdateOperationTypesReset}); err != nil { + updatePayload := gallerysharingupdate.SharingUpdate{ + OperationType: gallerysharingupdate.SharingUpdateOperationTypesReset, + } + if err = gallerySharingUpdateClient.GallerySharingProfileUpdateThenPoll(ctx, *id, updatePayload); err != nil { return fmt.Errorf("reseting community sharing of %s: %+v", id, err) } } diff --git a/internal/services/compute/shared_image_gallery_resource_test.go b/internal/services/compute/shared_image_gallery_resource_test.go index 9dc421493781..e81d9bb26a71 100644 --- a/internal/services/compute/shared_image_gallery_resource_test.go +++ b/internal/services/compute/shared_image_gallery_resource_test.go @@ -10,6 +10,7 @@ import ( "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/go-azure-sdk/resource-manager/compute/2022-03-03/galleries" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" @@ -142,7 +143,7 @@ func TestAccSharedImageGallery_privateGallery(t *testing.T) { } func (t SharedImageGalleryResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { - id, err := galleries.ParseGalleryID(state.ID) + id, err := commonids.ParseSharedImageGalleryID(state.ID) if err != nil { return nil, err } diff --git a/internal/services/labservice/lab_service_plan_resource.go b/internal/services/labservice/lab_service_plan_resource.go index 9396df6f1e43..315b93b6be1d 100644 --- a/internal/services/labservice/lab_service_plan_resource.go +++ b/internal/services/labservice/lab_service_plan_resource.go @@ -12,7 +12,6 @@ import ( "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" "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-03/galleries" "github.com/hashicorp/go-azure-sdk/resource-manager/labservices/2022-08-01/labplan" azValidate "github.com/hashicorp/terraform-provider-azurerm/helpers/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/sdk" @@ -188,7 +187,7 @@ func (r LabServicePlanResource) Arguments() map[string]*pluginsdk.Schema { "shared_gallery_id": { Type: pluginsdk.TypeString, Optional: true, - ValidateFunc: galleries.ValidateGalleryID, + ValidateFunc: commonids.ValidateSharedImageGalleryID, }, "support": {