Skip to content

Commit

Permalink
refactor: updating arckubernetes, bot, hsm and hybridcompute
Browse files Browse the repository at this point in the history
…to use `go-azure-sdk`'s base layer
  • Loading branch information
tombuildsstuff committed Aug 4, 2023
1 parent 5360782 commit 65ddfbd
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 35 deletions.
12 changes: 9 additions & 3 deletions internal/clients/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,9 @@ func (client *Client) Build(ctx context.Context, o *common.ClientOptions) error
return fmt.Errorf("building clients for Batch: %+v", err)
}
client.Blueprints = blueprints.NewClient(o)
client.Bot = bot.NewClient(o)
if client.Bot, err = bot.NewClient(o); err != nil {
return fmt.Errorf("building clients for Bot: %+v", err)
}
client.Cdn = cdn.NewClient(o)
if client.Cognitive, err = cognitiveServices.NewClient(o); err != nil {
return fmt.Errorf("building clients for Cognitive: %+v", err)
Expand Down Expand Up @@ -415,12 +417,16 @@ func (client *Client) Build(ctx context.Context, o *common.ClientOptions) error
if client.HPCCache, err = hpccache.NewClient(o); err != nil {
return fmt.Errorf("building clients for HPC Cache: %+v", err)
}
client.HSM = hsm.NewClient(o)
if client.HSM, err = hsm.NewClient(o); err != nil {
return fmt.Errorf("building clients for HSM: %+v", err)
}
client.HDInsight = hdinsight.NewClient(o)
if client.HealthCare, err = healthcare.NewClient(o); err != nil {
return fmt.Errorf("building clients for HealthCare: %+v", err)
}
client.HybridCompute = hybridcompute.NewClient(o)
if client.HybridCompute, err = hybridcompute.NewClient(o); err != nil {
return fmt.Errorf("building clients for HybridCompute: %+v", err)
}
if client.IoTCentral, err = iotcentral.NewClient(o); err != nil {
return fmt.Errorf("building clients for IoTCentral: %+v", err)
}
Expand Down
14 changes: 8 additions & 6 deletions internal/services/arckubernetes/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,26 @@ type Client struct {
}

func NewClient(o *common.ClientOptions) (*Client, error) {

arcKubernetesClient := connectedclusters.NewConnectedClustersClientWithBaseURI(o.ResourceManagerEndpoint)
o.ConfigureClient(&arcKubernetesClient.Client, o.ResourceManagerAuthorizer)
arcKubernetesClient, err := connectedclusters.NewConnectedClustersClientWithBaseURI(o.Environment.ResourceManager)
if err != nil {
return nil, fmt.Errorf("building ConnectedClusters client: %+v", err)
}
o.Configure(arcKubernetesClient.Client, o.Authorizers.ResourceManager)

extensionsClient, err := extensions.NewExtensionsClientWithBaseURI(o.Environment.ResourceManager)
if err != nil {
return nil, fmt.Errorf("building Extensions Client: %+v", err)
return nil, fmt.Errorf("building Extensions client: %+v", err)
}
o.Configure(extensionsClient.Client, o.Authorizers.ResourceManager)

fluxConfigurationClient, err := fluxconfiguration.NewFluxConfigurationClientWithBaseURI(o.Environment.ResourceManager)
if err != nil {
return nil, fmt.Errorf("building Flux Configuration Client: %+v", err)
return nil, fmt.Errorf("building FluxConfiguration client: %+v", err)
}
o.Configure(fluxConfigurationClient.Client, o.Authorizers.ResourceManager)

return &Client{
ArcKubernetesClient: &arcKubernetesClient,
ArcKubernetesClient: arcKubernetesClient,
ExtensionsClient: extensionsClient,
FluxConfigurationClient: fluxConfigurationClient,
}, nil
Expand Down
17 changes: 11 additions & 6 deletions internal/services/bot/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
package client

import (
"github.com/Azure/go-autorest/autorest"
"fmt"

healthbot_2022_08_08 "github.com/hashicorp/go-azure-sdk/resource-manager/healthbot/2022-08-08"
"github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager"
"github.com/hashicorp/terraform-provider-azurerm/internal/common"
"github.com/tombuildsstuff/kermit/sdk/botservice/2021-05-01-preview/botservice"
)
Expand All @@ -17,7 +19,7 @@ type Client struct {
HealthBotClient *healthbot_2022_08_08.Client
}

func NewClient(o *common.ClientOptions) *Client {
func NewClient(o *common.ClientOptions) (*Client, error) {
botClient := botservice.NewBotsClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId)
o.ConfigureClient(&botClient.Client, o.ResourceManagerAuthorizer)

Expand All @@ -27,14 +29,17 @@ func NewClient(o *common.ClientOptions) *Client {
channelClient := botservice.NewChannelsClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId)
o.ConfigureClient(&channelClient.Client, o.ResourceManagerAuthorizer)

healthBotsClient := healthbot_2022_08_08.NewClientWithBaseURI(o.ResourceManagerEndpoint, func(c *autorest.Client) {
o.ConfigureClient(c, o.ResourceManagerAuthorizer)
healthBotsClient, err := healthbot_2022_08_08.NewClientWithBaseURI(o.Environment.ResourceManager, func(c *resourcemanager.Client) {
o.Configure(c, o.Authorizers.ResourceManager)
})
if err != nil {
return nil, fmt.Errorf("building HealthBots client: %+v", err)
}

return &Client{
BotClient: &botClient,
ChannelClient: &channelClient,
ConnectionClient: &connectionClient,
HealthBotClient: &healthBotsClient,
}
HealthBotClient: healthBotsClient,
}, nil
}
15 changes: 10 additions & 5 deletions internal/services/hsm/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
package client

import (
"fmt"

"github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2021-11-30/dedicatedhsms"
"github.com/hashicorp/terraform-provider-azurerm/internal/common"
)
Expand All @@ -12,11 +14,14 @@ type Client struct {
DedicatedHsmClient *dedicatedhsms.DedicatedHsmsClient
}

func NewClient(o *common.ClientOptions) *Client {
dedicatedHsmClient := dedicatedhsms.NewDedicatedHsmsClientWithBaseURI(o.ResourceManagerEndpoint)
o.ConfigureClient(&dedicatedHsmClient.Client, o.ResourceManagerAuthorizer)
func NewClient(o *common.ClientOptions) (*Client, error) {
dedicatedHsmClient, err := dedicatedhsms.NewDedicatedHsmsClientWithBaseURI(o.Environment.ResourceManager)
if err != nil {
return nil, fmt.Errorf("building DedicatedHsms client: %+v", err)
}
o.Configure(dedicatedHsmClient.Client, o.Authorizers.ResourceManager)

return &Client{
DedicatedHsmClient: &dedicatedHsmClient,
}
DedicatedHsmClient: dedicatedHsmClient,
}, nil
}
43 changes: 28 additions & 15 deletions internal/services/hybridcompute/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
package client

import (
"fmt"

"github.com/hashicorp/go-azure-sdk/resource-manager/hybridcompute/2022-11-10/machineextensions"
"github.com/hashicorp/go-azure-sdk/resource-manager/hybridcompute/2022-11-10/machines"
"github.com/hashicorp/go-azure-sdk/resource-manager/hybridcompute/2022-11-10/privateendpointconnections"
Expand All @@ -18,24 +20,35 @@ type Client struct {
PrivateLinkScopesClient *privatelinkscopes.PrivateLinkScopesClient
}

func NewClient(o *common.ClientOptions) *Client {

machineExtensionsClient := machineextensions.NewMachineExtensionsClientWithBaseURI(o.ResourceManagerEndpoint)
o.ConfigureClient(&machineExtensionsClient.Client, o.ResourceManagerAuthorizer)
func NewClient(o *common.ClientOptions) (*Client, error) {
machineExtensionsClient, err := machineextensions.NewMachineExtensionsClientWithBaseURI(o.Environment.ResourceManager)
if err != nil {
return nil, fmt.Errorf("building MachineExtensions client: %+v", err)
}
o.Configure(machineExtensionsClient.Client, o.Authorizers.ResourceManager)

machinesClient := machines.NewMachinesClientWithBaseURI(o.ResourceManagerEndpoint)
o.ConfigureClient(&machinesClient.Client, o.ResourceManagerAuthorizer)
machinesClient, err := machines.NewMachinesClientWithBaseURI(o.Environment.ResourceManager)
if err != nil {
return nil, fmt.Errorf("building Machines client: %+v", err)
}
o.Configure(machinesClient.Client, o.Authorizers.ResourceManager)

privateEndpointConnectionsClient := privateendpointconnections.NewPrivateEndpointConnectionsClientWithBaseURI(o.ResourceManagerEndpoint)
o.ConfigureClient(&privateEndpointConnectionsClient.Client, o.ResourceManagerAuthorizer)
privateEndpointConnectionsClient, err := privateendpointconnections.NewPrivateEndpointConnectionsClientWithBaseURI(o.Environment.ResourceManager)
if err != nil {
return nil, fmt.Errorf("building PrivateEndpointConnections client: %+v", err)
}
o.Configure(privateEndpointConnectionsClient.Client, o.Authorizers.ResourceManager)

privateLinkScopesClient := privatelinkscopes.NewPrivateLinkScopesClientWithBaseURI(o.ResourceManagerEndpoint)
o.ConfigureClient(&privateLinkScopesClient.Client, o.ResourceManagerAuthorizer)
privateLinkScopesClient, err := privatelinkscopes.NewPrivateLinkScopesClientWithBaseURI(o.Environment.ResourceManager)
if err != nil {
return nil, fmt.Errorf("building PrivateLinkScopes client: %+v", err)
}
o.Configure(privateLinkScopesClient.Client, o.Authorizers.ResourceManager)

return &Client{
MachineExtensionsClient: &machineExtensionsClient,
MachinesClient: &machinesClient,
PrivateEndpointConnectionsClient: &privateEndpointConnectionsClient,
PrivateLinkScopesClient: &privateLinkScopesClient,
}
MachineExtensionsClient: machineExtensionsClient,
MachinesClient: machinesClient,
PrivateEndpointConnectionsClient: privateEndpointConnectionsClient,
PrivateLinkScopesClient: privateLinkScopesClient,
}, nil
}

0 comments on commit 65ddfbd

Please sign in to comment.