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

refactor: templatespecversions now uses hashicorp/go-azure-sdk / updates to API Version 2022-02-01 #24007

Merged
merged 1 commit into from
Nov 23, 2023
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
15 changes: 9 additions & 6 deletions internal/services/resource/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ package client
import (
"fmt"

"github.com/Azure/azure-sdk-for-go/services/preview/resources/mgmt/2019-06-01-preview/templatespecs" // nolint: staticcheck
"github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2020-06-01/resources" // nolint: staticcheck
"github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2020-06-01/resources" // nolint: staticcheck
"github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks"
"github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/privatelinkassociation"
"github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/resourcemanagementprivatelink"
"github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-10-01/deploymentscripts"
"github.com/hashicorp/go-azure-sdk/resource-manager/resources/2021-07-01/features"
"github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-02-01/templatespecversions"
"github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers"
"github.com/hashicorp/terraform-provider-azurerm/internal/common"
)
Expand All @@ -28,7 +28,7 @@ type Client struct {
ResourceProvidersClient *providers.ProvidersClient
ResourcesClient *resources.Client
TagsClient *resources.TagsClient
TemplateSpecsVersionsClient *templatespecs.VersionsClient
TemplateSpecsVersionsClient *templatespecversions.TemplateSpecVersionsClient

options *common.ClientOptions
}
Expand Down Expand Up @@ -79,8 +79,11 @@ func NewClient(o *common.ClientOptions) (*Client, error) {
resourcesClient := resources.NewClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId)
o.ConfigureClient(&resourcesClient.Client, o.ResourceManagerAuthorizer)

templatespecsVersionsClient := templatespecs.NewVersionsClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId)
o.ConfigureClient(&templatespecsVersionsClient.Client, o.ResourceManagerAuthorizer)
templateSpecsVersionsClient, err := templatespecversions.NewTemplateSpecVersionsClientWithBaseURI(o.Environment.ResourceManager)
if err != nil {
return nil, fmt.Errorf("building TemplateSpecVersions client: %+v", err)
}
o.Configure(templateSpecsVersionsClient.Client, o.Authorizers.ResourceManager)

tagsClient := resources.NewTagsClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId)
o.ConfigureClient(&tagsClient.Client, o.ResourceManagerAuthorizer)
Expand All @@ -96,7 +99,7 @@ func NewClient(o *common.ClientOptions) (*Client, error) {
ResourceProvidersClient: resourceProvidersClient,
ResourcesClient: &resourcesClient,
TagsClient: &tagsClient,
TemplateSpecsVersionsClient: &templatespecsVersionsClient,
TemplateSpecsVersionsClient: templateSpecsVersionsClient,

options: o,
}, nil
Expand Down
36 changes: 18 additions & 18 deletions internal/services/resource/template_spec_version_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ import (
"fmt"
"time"

"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/go-azure-sdk/resource-manager/resources/2022-02-01/templatespecversions"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/resource/parse"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/resource/validate"
"github.com/hashicorp/terraform-provider-azurerm/internal/tags"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk"
"github.com/hashicorp/terraform-provider-azurerm/internal/timeouts"
"github.com/hashicorp/terraform-provider-azurerm/utils"
)

func dataSourceTemplateSpecVersion() *pluginsdk.Resource {
Expand Down Expand Up @@ -46,7 +46,7 @@ func dataSourceTemplateSpecVersion() *pluginsdk.Resource {
Computed: true,
},

"tags": tags.SchemaDataSource(),
"tags": commonschema.TagsDataSource(),
},
}
}
Expand All @@ -57,28 +57,28 @@ func dataSourceTemplateSpecVersionRead(d *pluginsdk.ResourceData, meta interface
ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d)
defer cancel()

id := parse.NewTemplateSpecVersionID(subscriptionId, d.Get("resource_group_name").(string), d.Get("name").(string), d.Get("version").(string))

resp, err := client.Get(ctx, id.ResourceGroup, id.TemplateSpecName, id.VersionName)
id := templatespecversions.NewTemplateSpecVersionID(subscriptionId, d.Get("resource_group_name").(string), d.Get("name").(string), d.Get("version").(string))
resp, err := client.Get(ctx, id)
if err != nil {
if utils.ResponseWasNotFound(resp.Response) {
return fmt.Errorf("Templatespec %q, with version name %q (resource group %q) was not found: %+v", id.TemplateSpecName, id.VersionName, id.ResourceGroup, err)
if response.WasNotFound(resp.HttpResponse) {
return fmt.Errorf("%s was not found", id)
}
return fmt.Errorf("reading Templatespec %q, with version name %q (resource group %q): %+v", id.TemplateSpecName, id.VersionName, id.ResourceGroup, err)
return fmt.Errorf("retrieving %s: %+v", id, err)
}

templateBody := "{}"
if props := resp.VersionProperties; props != nil && props.Template != nil {
templateBodyRaw, err := flattenTemplateDeploymentBody(props.Template)
d.SetId(id.ID())

if model := resp.Model; model != nil {
templateBodyRaw, err := flattenTemplateDeploymentBody(model.Properties.MainTemplate)
if err != nil {
return err
}
d.Set("template_body", templateBodyRaw)

templateBody = *templateBodyRaw
if err := tags.FlattenAndSet(d, model.Tags); err != nil {
return err
}
}
d.Set("template_body", templateBody)

d.SetId(id.ID())

return tags.FlattenAndSet(d, resp.Tags)
return nil
}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading
Loading