Skip to content

Commit

Permalink
Merge pull request #17434 from hashicorp/f/maps-to-go-azure-sdk
Browse files Browse the repository at this point in the history
maps: refactoring to use `go-azure-sdk`
  • Loading branch information
tombuildsstuff authored Jun 30, 2022
2 parents 36ed2ae + be52d22 commit 51345b5
Show file tree
Hide file tree
Showing 64 changed files with 486 additions and 4,368 deletions.
4 changes: 2 additions & 2 deletions internal/services/maps/client/client.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package client

import (
"github.com/hashicorp/go-azure-sdk/resource-manager/maps/2021-02-01/accounts"
"github.com/hashicorp/go-azure-sdk/resource-manager/maps/2021-02-01/creators"
"github.com/hashicorp/terraform-provider-azurerm/internal/common"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/maps/sdk/2021-02-01/accounts"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/maps/sdk/2021-02-01/creators"
)

type Client struct {
Expand Down
7 changes: 3 additions & 4 deletions internal/services/maps/maps_account_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ import (
"github.com/hashicorp/go-azure-helpers/lang/response"
"github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema"
"github.com/hashicorp/go-azure-helpers/resourcemanager/tags"
"github.com/hashicorp/terraform-provider-azurerm/helpers/azure"
"github.com/hashicorp/go-azure-sdk/resource-manager/maps/2021-02-01/accounts"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/maps/sdk/2021-02-01/accounts"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/maps/validate"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk"
"github.com/hashicorp/terraform-provider-azurerm/internal/timeouts"
Expand All @@ -30,7 +29,7 @@ func dataSourceMapsAccount() *pluginsdk.Resource {
ValidateFunc: validate.AccountName(),
},

"resource_group_name": azure.SchemaResourceGroupName(),
"resource_group_name": commonschema.ResourceGroupNameForDataSource(),

"sku_name": {
Type: pluginsdk.TypeString,
Expand Down Expand Up @@ -81,7 +80,7 @@ func dataSourceMapsAccountRead(d *pluginsdk.ResourceData, meta interface{}) erro
d.Set("resource_group_name", id.ResourceGroupName)

if model := resp.Model; model != nil {
d.Set("sku_name", model.Sku.Name)
d.Set("sku_name", string(model.Sku.Name))
if props := model.Properties; props != nil {
d.Set("x_ms_client_id", props.UniqueId)
}
Expand Down
14 changes: 6 additions & 8 deletions internal/services/maps/maps_account_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@ import (
"log"
"time"

"github.com/Azure/azure-sdk-for-go/services/maps/mgmt/2021-02-01/maps"
"github.com/hashicorp/go-azure-helpers/lang/response"
"github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema"
"github.com/hashicorp/go-azure-helpers/resourcemanager/tags"
"github.com/hashicorp/terraform-provider-azurerm/helpers/azure"
"github.com/hashicorp/go-azure-sdk/resource-manager/maps/2021-02-01/accounts"
"github.com/hashicorp/terraform-provider-azurerm/helpers/tf"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/maps/sdk/2021-02-01/accounts"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/maps/validate"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation"
Expand Down Expand Up @@ -46,16 +44,16 @@ func resourceMapsAccount() *pluginsdk.Resource {
ValidateFunc: validate.AccountName(),
},

"resource_group_name": azure.SchemaResourceGroupName(),
"resource_group_name": commonschema.ResourceGroupName(),

"sku_name": {
Type: pluginsdk.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: validation.StringInSlice([]string{
string(maps.NameS0),
string(maps.NameS1),
string(maps.NameG2),
string(accounts.NameSZero),
string(accounts.NameSOne),
string(accounts.NameGTwo),
}, false),
},

Expand Down Expand Up @@ -146,7 +144,7 @@ func resourceMapsAccountRead(d *pluginsdk.ResourceData, meta interface{}) error
d.Set("resource_group_name", id.ResourceGroupName)

if model := resp.Model; model != nil {
d.Set("sku_name", model.Sku.Name)
d.Set("sku_name", string(model.Sku.Name))
if props := model.Properties; props != nil {
d.Set("x_ms_client_id", props.UniqueId)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/services/maps/maps_account_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import (
"fmt"
"testing"

"github.com/hashicorp/go-azure-sdk/resource-manager/maps/2021-02-01/accounts"
"github.com/hashicorp/terraform-provider-azurerm/internal/acceptance"
"github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/maps/sdk/2021-02-01/accounts"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk"
"github.com/hashicorp/terraform-provider-azurerm/utils"
)
Expand Down
8 changes: 3 additions & 5 deletions internal/services/maps/maps_creator_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@ import (
"github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema"
"github.com/hashicorp/go-azure-helpers/resourcemanager/location"
"github.com/hashicorp/go-azure-helpers/resourcemanager/tags"
"github.com/hashicorp/terraform-provider-azurerm/helpers/azure"
"github.com/hashicorp/go-azure-sdk/resource-manager/maps/2021-02-01/accounts"
"github.com/hashicorp/go-azure-sdk/resource-manager/maps/2021-02-01/creators"
"github.com/hashicorp/terraform-provider-azurerm/helpers/tf"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/maps/sdk/2021-02-01/accounts"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/maps/sdk/2021-02-01/creators"
"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 @@ -89,9 +88,8 @@ func resourceMapsCreatorCreateUpdate(d *pluginsdk.ResourceData, meta interface{}
}
}

location := azure.NormalizeLocation(d.Get("location"))
props := creators.Creator{
Location: location,
Location: location.Normalize(d.Get("location").(string)),
Properties: creators.CreatorProperties{
StorageUnits: int64(d.Get("storage_units").(int)),
},
Expand Down
2 changes: 1 addition & 1 deletion internal/services/maps/maps_creator_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import (
"testing"

"github.com/hashicorp/go-azure-helpers/lang/response"
"github.com/hashicorp/go-azure-sdk/resource-manager/maps/2021-02-01/creators"
"github.com/hashicorp/terraform-provider-azurerm/internal/acceptance"
"github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/maps/sdk/2021-02-01/creators"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk"
"github.com/hashicorp/terraform-provider-azurerm/utils"
)
Expand Down
Loading

0 comments on commit 51345b5

Please sign in to comment.