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

trafficmanager: refactoring to use go-azure-sdk #17383

Merged
merged 3 commits into from
Jun 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions internal/services/trafficmanager/azure_endpoint_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@ import (
"time"

"github.com/hashicorp/go-azure-helpers/lang/response"
"github.com/hashicorp/go-azure-sdk/resource-manager/trafficmanager/2018-08-01/endpoints"
"github.com/hashicorp/go-azure-sdk/resource-manager/trafficmanager/2018-08-01/profiles"
"github.com/hashicorp/terraform-provider-azurerm/helpers/azure"
"github.com/hashicorp/terraform-provider-azurerm/helpers/tf"
azValidate "github.com/hashicorp/terraform-provider-azurerm/helpers/validate"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/trafficmanager/parse"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/trafficmanager/sdk/2018-08-01/endpoints"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/trafficmanager/validate"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk"
azSchema "github.com/hashicorp/terraform-provider-azurerm/internal/tf/schema"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation"
Expand Down Expand Up @@ -57,7 +56,7 @@ func resourceAzureEndpoint() *pluginsdk.Resource {
Type: pluginsdk.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: validate.TrafficManagerProfileID,
ValidateFunc: profiles.ValidateTrafficManagerProfileID,
},

"target_resource_id": {
Expand Down Expand Up @@ -143,12 +142,12 @@ func resourceAzureEndpointCreateUpdate(d *pluginsdk.ResourceData, meta interface
ctx, cancel := timeouts.ForCreateUpdate(meta.(*clients.Client).StopContext, d)
defer cancel()

profileId, err := parse.TrafficManagerProfileID(d.Get("profile_id").(string))
profileId, err := profiles.ParseTrafficManagerProfileID(d.Get("profile_id").(string))
if err != nil {
return fmt.Errorf("parsing `profile_id`: %+v", err)
}

id := endpoints.NewEndpointTypeID(profileId.SubscriptionId, profileId.ResourceGroup, profileId.Name, endpoints.EndpointTypeAzureEndpoints, d.Get("name").(string))
id := endpoints.NewEndpointTypeID(profileId.SubscriptionId, profileId.ResourceGroupName, profileId.ProfileName, endpoints.EndpointTypeAzureEndpoints, d.Get("name").(string))
if d.IsNewResource() {
existing, err := client.Get(ctx, id)
if err != nil {
Expand Down Expand Up @@ -220,7 +219,7 @@ func resourceAzureEndpointRead(d *pluginsdk.ResourceData, meta interface{}) erro
}

d.Set("name", id.EndpointName)
d.Set("profile_id", parse.NewTrafficManagerProfileID(id.SubscriptionId, id.ResourceGroupName, id.ProfileName).ID())
d.Set("profile_id", profiles.NewTrafficManagerProfileID(id.SubscriptionId, id.ResourceGroupName, id.ProfileName).ID())

if model := resp.Model; model != nil {
if props := model.Properties; props != nil {
Expand Down
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/trafficmanager/2018-08-01/endpoints"
"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/trafficmanager/sdk/2018-08-01/endpoints"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk"
"github.com/hashicorp/terraform-provider-azurerm/utils"
)
Expand Down
6 changes: 3 additions & 3 deletions internal/services/trafficmanager/client/client.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package client

import (
"github.com/hashicorp/go-azure-sdk/resource-manager/trafficmanager/2018-08-01/endpoints"
"github.com/hashicorp/go-azure-sdk/resource-manager/trafficmanager/2018-08-01/geographichierarchies"
"github.com/hashicorp/go-azure-sdk/resource-manager/trafficmanager/2018-08-01/profiles"
"github.com/hashicorp/terraform-provider-azurerm/internal/common"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/trafficmanager/sdk/2018-08-01/endpoints"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/trafficmanager/sdk/2018-08-01/geographichierarchies"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/trafficmanager/sdk/2018-08-01/profiles"
)

type Client struct {
Expand Down
2 changes: 1 addition & 1 deletion internal/services/trafficmanager/endpoint.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package trafficmanager

import (
"github.com/hashicorp/terraform-provider-azurerm/internal/services/trafficmanager/sdk/2018-08-01/endpoints"
"github.com/hashicorp/go-azure-sdk/resource-manager/trafficmanager/2018-08-01/endpoints"
"github.com/hashicorp/terraform-provider-azurerm/utils"
)

Expand Down
13 changes: 6 additions & 7 deletions internal/services/trafficmanager/external_endpoint_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@ import (

"github.com/hashicorp/go-azure-helpers/lang/response"
"github.com/hashicorp/go-azure-helpers/resourcemanager/location"
"github.com/hashicorp/go-azure-sdk/resource-manager/trafficmanager/2018-08-01/endpoints"
"github.com/hashicorp/go-azure-sdk/resource-manager/trafficmanager/2018-08-01/profiles"
"github.com/hashicorp/terraform-provider-azurerm/helpers/tf"
azValidate "github.com/hashicorp/terraform-provider-azurerm/helpers/validate"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/trafficmanager/parse"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/trafficmanager/sdk/2018-08-01/endpoints"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/trafficmanager/validate"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk"
azSchema "github.com/hashicorp/terraform-provider-azurerm/internal/tf/schema"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation"
Expand Down Expand Up @@ -57,7 +56,7 @@ func resourceExternalEndpoint() *pluginsdk.Resource {
Type: pluginsdk.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: validate.TrafficManagerProfileID,
ValidateFunc: profiles.ValidateTrafficManagerProfileID,
},

"target": {
Expand Down Expand Up @@ -151,12 +150,12 @@ func resourceExternalEndpointCreateUpdate(d *pluginsdk.ResourceData, meta interf
ctx, cancel := timeouts.ForCreateUpdate(meta.(*clients.Client).StopContext, d)
defer cancel()

profileId, err := parse.TrafficManagerProfileID(d.Get("profile_id").(string))
profileId, err := profiles.ParseTrafficManagerProfileID(d.Get("profile_id").(string))
if err != nil {
return fmt.Errorf("parsing `profile_id`: %+v", err)
}

id := endpoints.NewEndpointTypeID(profileId.SubscriptionId, profileId.ResourceGroup, profileId.Name, endpoints.EndpointTypeExternalEndpoints, d.Get("name").(string))
id := endpoints.NewEndpointTypeID(profileId.SubscriptionId, profileId.ResourceGroupName, profileId.ProfileName, endpoints.EndpointTypeExternalEndpoints, d.Get("name").(string))
if d.IsNewResource() {
existing, err := client.Get(ctx, id)
if err != nil {
Expand Down Expand Up @@ -232,7 +231,7 @@ func resourceExternalEndpointRead(d *pluginsdk.ResourceData, meta interface{}) e
}

d.Set("name", id.EndpointName)
d.Set("profile_id", parse.NewTrafficManagerProfileID(id.SubscriptionId, id.ResourceGroupName, id.ProfileName).ID())
d.Set("profile_id", profiles.NewTrafficManagerProfileID(id.SubscriptionId, id.ResourceGroupName, id.ProfileName).ID())

if model := resp.Model; model != nil {
if props := model.Properties; props != nil {
Expand Down
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/trafficmanager/2018-08-01/endpoints"
"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/trafficmanager/sdk/2018-08-01/endpoints"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk"
"github.com/hashicorp/terraform-provider-azurerm/utils"
)
Expand Down
13 changes: 6 additions & 7 deletions internal/services/trafficmanager/nested_endpoint_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@ import (

"github.com/hashicorp/go-azure-helpers/lang/response"
"github.com/hashicorp/go-azure-helpers/resourcemanager/location"
"github.com/hashicorp/go-azure-sdk/resource-manager/trafficmanager/2018-08-01/endpoints"
"github.com/hashicorp/go-azure-sdk/resource-manager/trafficmanager/2018-08-01/profiles"
"github.com/hashicorp/terraform-provider-azurerm/helpers/azure"
"github.com/hashicorp/terraform-provider-azurerm/helpers/tf"
azValidate "github.com/hashicorp/terraform-provider-azurerm/helpers/validate"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/trafficmanager/parse"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/trafficmanager/sdk/2018-08-01/endpoints"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/trafficmanager/validate"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk"
azSchema "github.com/hashicorp/terraform-provider-azurerm/internal/tf/schema"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation"
Expand Down Expand Up @@ -58,7 +57,7 @@ func resourceNestedEndpoint() *pluginsdk.Resource {
Type: pluginsdk.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: validate.TrafficManagerProfileID,
ValidateFunc: profiles.ValidateTrafficManagerProfileID,
},

"target_resource_id": {
Expand Down Expand Up @@ -168,12 +167,12 @@ func resourceNestedEndpointCreateUpdate(d *pluginsdk.ResourceData, meta interfac
ctx, cancel := timeouts.ForCreateUpdate(meta.(*clients.Client).StopContext, d)
defer cancel()

profileId, err := parse.TrafficManagerProfileID(d.Get("profile_id").(string))
profileId, err := profiles.ParseTrafficManagerProfileID(d.Get("profile_id").(string))
if err != nil {
return fmt.Errorf("parsing `profile_id`: %+v", err)
}

id := endpoints.NewEndpointTypeID(profileId.SubscriptionId, profileId.ResourceGroup, profileId.Name, endpoints.EndpointTypeNestedEndpoints, d.Get("name").(string))
id := endpoints.NewEndpointTypeID(profileId.SubscriptionId, profileId.ResourceGroupName, profileId.ProfileName, endpoints.EndpointTypeNestedEndpoints, d.Get("name").(string))

if d.IsNewResource() {
existing, err := client.Get(ctx, id)
Expand Down Expand Up @@ -261,7 +260,7 @@ func resourceNestedEndpointRead(d *pluginsdk.ResourceData, meta interface{}) err
}

d.Set("name", id.EndpointName)
d.Set("profile_id", parse.NewTrafficManagerProfileID(id.SubscriptionId, id.ResourceGroupName, id.ProfileName).ID())
d.Set("profile_id", profiles.NewTrafficManagerProfileID(id.SubscriptionId, id.ResourceGroupName, id.ProfileName).ID())

if model := resp.Model; model != nil {
if props := model.Properties; props != nil {
Expand Down
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/trafficmanager/2018-08-01/endpoints"
"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/trafficmanager/sdk/2018-08-01/endpoints"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk"
"github.com/hashicorp/terraform-provider-azurerm/utils"
)
Expand Down
75 changes: 0 additions & 75 deletions internal/services/trafficmanager/parse/azure_endpoint.go

This file was deleted.

Loading