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

policy.guestconfigurationassignments: migrate to hashicorp/go-azure-sdk #21927

Merged
merged 3 commits into from
Jun 1, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
4 changes: 3 additions & 1 deletion internal/clients/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,9 @@ func (client *Client) Build(ctx context.Context, o *common.ClientOptions) error
}
client.NotificationHubs = notificationhub.NewClient(o)
client.Orbital = orbital.NewClient(o)
client.Policy = policy.NewClient(o)
if client.Policy, err = policy.NewClient(o); err != nil {
return fmt.Errorf("building clients for Policy: %+v", err)
}
if client.Portal, err = portal.NewClient(o); err != nil {
return fmt.Errorf("building clients for Portal: %+v", err)
}
Expand Down
21 changes: 13 additions & 8 deletions internal/services/policy/client/client.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package client

import (
"github.com/Azure/azure-sdk-for-go/services/guestconfiguration/mgmt/2020-06-25/guestconfiguration" // nolint: staticcheck
"github.com/Azure/azure-sdk-for-go/services/preview/resources/mgmt/2021-06-01-preview/policy" // nolint: staticcheck
"fmt"

"github.com/Azure/azure-sdk-for-go/services/preview/resources/mgmt/2021-06-01-preview/policy" // nolint: staticcheck
"github.com/hashicorp/go-azure-sdk/resource-manager/guestconfiguration/2020-06-25/guestconfigurationassignments"
"github.com/hashicorp/go-azure-sdk/resource-manager/policyinsights/2021-10-01/remediations"
assignments "github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-06-01/policyassignments"
"github.com/hashicorp/terraform-provider-azurerm/internal/common"
Expand All @@ -14,10 +16,10 @@ type Client struct {
ExemptionsClient *policy.ExemptionsClient
SetDefinitionsClient *policy.SetDefinitionsClient
RemediationsClient *remediations.RemediationsClient
GuestConfigurationAssignmentsClient *guestconfiguration.AssignmentsClient
GuestConfigurationAssignmentsClient *guestconfigurationassignments.GuestConfigurationAssignmentsClient
}

func NewClient(o *common.ClientOptions) *Client {
func NewClient(o *common.ClientOptions) (*Client, error) {
assignmentsClient := assignments.NewPolicyAssignmentsClientWithBaseURI(o.ResourceManagerEndpoint)
o.ConfigureClient(&assignmentsClient.Client, o.ResourceManagerAuthorizer)

Expand All @@ -33,15 +35,18 @@ func NewClient(o *common.ClientOptions) *Client {
remediationsClient := remediations.NewRemediationsClientWithBaseURI(o.ResourceManagerEndpoint)
o.ConfigureClient(&remediationsClient.Client, o.ResourceManagerAuthorizer)

guestConfigurationAssignmentsClient := guestconfiguration.NewAssignmentsClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId)
o.ConfigureClient(&guestConfigurationAssignmentsClient.Client, o.ResourceManagerAuthorizer)
guestConfigurationAssignmentsClient, err := guestconfigurationassignments.NewGuestConfigurationAssignmentsClientWithBaseURI(o.Environment.ResourceManager)
if err != nil {
return nil, fmt.Errorf("building Guest Configuration Assignments Client client: %+v", err)
katbyte marked this conversation as resolved.
Show resolved Hide resolved
}
o.Configure(guestConfigurationAssignmentsClient.Client, o.Authorizers.ResourceManager)

return &Client{
AssignmentsClient: &assignmentsClient,
DefinitionsClient: &definitionsClient,
ExemptionsClient: &exemptionsClient,
SetDefinitionsClient: &setDefinitionsClient,
RemediationsClient: &remediationsClient,
GuestConfigurationAssignmentsClient: &guestConfigurationAssignmentsClient,
}
GuestConfigurationAssignmentsClient: guestConfigurationAssignmentsClient,
}, nil
}

This file was deleted.

Loading