Skip to content

Commit

Permalink
Interim
Browse files Browse the repository at this point in the history
  • Loading branch information
favoretti committed Jan 19, 2024
1 parent 18967e1 commit 305c360
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
22 changes: 12 additions & 10 deletions internal/services/legacy/virtual_machine_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ func resourceVirtualMachine() *pluginsdk.Resource {
DiffSuppressFunc: suppress.CaseDifference,
},

//lintignore:S018
// lintignore:S018
"storage_image_reference": {
Type: pluginsdk.TypeSet,
Optional: true,
Expand Down Expand Up @@ -434,7 +434,7 @@ func resourceVirtualMachine() *pluginsdk.Resource {
},
},

//lintignore:S018
// lintignore:S018
"os_profile": {
Type: pluginsdk.TypeSet,
Optional: true,
Expand Down Expand Up @@ -470,7 +470,7 @@ func resourceVirtualMachine() *pluginsdk.Resource {
Set: resourceVirtualMachineStorageOsProfileHash,
},

//lintignore:S018
// lintignore:S018
"os_profile_windows_config": {
Type: pluginsdk.TypeSet,
Optional: true,
Expand Down Expand Up @@ -555,7 +555,7 @@ func resourceVirtualMachine() *pluginsdk.Resource {
ConflictsWith: []string{"os_profile_linux_config"},
},

//lintignore:S018
// lintignore:S018
"os_profile_linux_config": {
Type: pluginsdk.TypeSet,
Optional: true,
Expand Down Expand Up @@ -1032,18 +1032,20 @@ func resourceVirtualMachineDeleteVhd(ctx context.Context, storageClient *intStor
return fmt.Errorf("`vhd.URI` was nil`")
}

domainSuffix := storageClient.Environment.StorageEndpointSuffix

uri := *vhd.URI
id, err := blobs.ParseResourceID(uri)
id, err := blobs.ParseBlobID(uri, domainSuffix)
if err != nil {
return fmt.Errorf("parsing %q: %s", uri, err)
}

account, err := storageClient.FindAccount(ctx, id.AccountName)
account, err := storageClient.FindAccount(ctx, id.AccountId.AccountName)
if err != nil {
return fmt.Errorf("retrieving Account %q for Blob %q (Container %q): %s", id.AccountName, id.BlobName, id.ContainerName, err)
return fmt.Errorf("retrieving Account %q for Blob %q (Container %q): %s", id.AccountId.AccountName, id.BlobName, id.ContainerName, err)
}
if account == nil {
return fmt.Errorf("Unable to locate Storage Account %q (Disk %q)!", id.AccountName, uri)
return fmt.Errorf("Unable to locate Storage Account %q (Disk %q)!", id.AccountId.AccountName, uri)
}

if err != nil {
Expand All @@ -1058,8 +1060,8 @@ func resourceVirtualMachineDeleteVhd(ctx context.Context, storageClient *intStor
input := blobs.DeleteInput{
DeleteSnapshots: false,
}
if _, err := blobsClient.Delete(ctx, id.AccountName, id.ContainerName, id.BlobName, input); err != nil {
return fmt.Errorf("deleting Blob %q (Container %q / Account %q / Resource Group %q): %s", id.BlobName, id.ContainerName, id.AccountName, account.ResourceGroup, err)
if _, err := blobsClient.Delete(ctx, id.ContainerName, id.BlobName, input); err != nil {
return fmt.Errorf("deleting Blob %q (Container %q / Account %q / Resource Group %q): %s", id.BlobName, id.ContainerName, id.AccountId.AccountName, account.ResourceGroup, err)
}

return nil
Expand Down
5 changes: 3 additions & 2 deletions internal/services/legacy/virtual_machine_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"fmt"
"testing"

"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"
Expand Down Expand Up @@ -255,9 +256,9 @@ func (VirtualMachineResource) unmanagedDiskExistsInContainer(blobName string, sh
}

input := blobs.GetPropertiesInput{}
props, err := client.GetProperties(ctx, accountName, containerName, blobName, input)
props, err := client.GetProperties(ctx, containerName, blobName, input)
if err != nil {
if utils.ResponseWasNotFound(props.Response) {
if response.WasNotFound(props.HttpResponse.Response) {
if !shouldExist {
return nil
}
Expand Down

0 comments on commit 305c360

Please sign in to comment.