Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compute - update several resources to use go-azure-sdk #25533

Merged
merged 13 commits into from
Apr 15, 2024
  •  
  •  
  •  
183 changes: 104 additions & 79 deletions internal/services/compute/client/client.go

Large diffs are not rendered by default.

15 changes: 6 additions & 9 deletions internal/services/compute/edge_zone.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,24 @@ package compute

import (
"github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones"
"github.com/hashicorp/terraform-provider-azurerm/utils"
"github.com/tombuildsstuff/kermit/sdk/compute/2023-03-01/compute"
)

func expandEdgeZone(input string) *compute.ExtendedLocation {
func expandEdgeZone(input string) *edgezones.Model {
normalized := edgezones.Normalize(input)
if normalized == "" {
return nil
}

return &compute.ExtendedLocation{
Name: utils.String(normalized),
Type: compute.ExtendedLocationTypesEdgeZone,
return &edgezones.Model{
Name: normalized,
}
}

func flattenEdgeZone(input *compute.ExtendedLocation) string {
if input == nil || input.Type != compute.ExtendedLocationTypesEdgeZone || input.Name == nil {
func flattenEdgeZone(input *edgezones.Model) string {
if input == nil || input.Name == "" {
return ""
}
return edgezones.NormalizeNilable(input.Name)
return edgezones.Normalize(input.Name)
}

func expandManagedDiskEdgeZone(input string) *edgezones.Model {
Expand Down
24 changes: 12 additions & 12 deletions internal/services/compute/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,53 +6,53 @@ package compute
import (
"sort"

"github.com/hashicorp/go-azure-helpers/lang/pointer"
"github.com/hashicorp/go-azure-sdk/resource-manager/compute/2022-03-03/galleryimageversions"
"github.com/hashicorp/go-azure-sdk/resource-manager/compute/2024-03-01/virtualmachinescalesets"
"github.com/hashicorp/go-version"
"github.com/hashicorp/terraform-provider-azurerm/utils"
"github.com/tombuildsstuff/kermit/sdk/compute/2023-03-01/compute"
)

func expandIDsToSubResources(input []interface{}) *[]compute.SubResource {
ids := make([]compute.SubResource, 0)
func expandIDsToSubResources(input []interface{}) *[]virtualmachinescalesets.SubResource {
ids := make([]virtualmachinescalesets.SubResource, 0)

for _, v := range input {
ids = append(ids, compute.SubResource{
ID: utils.String(v.(string)),
ids = append(ids, virtualmachinescalesets.SubResource{
Id: pointer.To(v.(string)),
})
}

return &ids
}

func flattenSubResourcesToIDs(input *[]compute.SubResource) []interface{} {
func flattenSubResourcesToIDs(input *[]virtualmachinescalesets.SubResource) []interface{} {
ids := make([]interface{}, 0)
if input == nil {
return ids
}

for _, v := range *input {
if v.ID == nil {
if v.Id == nil {
continue
}

ids = append(ids, *v.ID)
ids = append(ids, *v.Id)
}

return ids
}

func flattenSubResourcesToStringIDs(input *[]compute.SubResource) []string {
func flattenSubResourcesToStringIDs(input *[]virtualmachinescalesets.SubResource) []string {
ids := make([]string, 0)
if input == nil {
return ids
}

for _, v := range *input {
if v.ID == nil {
if v.Id == nil {
continue
}

ids = append(ids, *v.ID)
ids = append(ids, *v.Id)
}

return ids
Expand Down
Loading
Loading