From 6d06b1871e70954fad788f5f26ca12112d2247ad Mon Sep 17 00:00:00 2001 From: Christoph Hartmann Date: Tue, 12 Dec 2023 18:57:03 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=B9=20ability=20to=20configure=20azure?= =?UTF-8?q?=20client=20(#2798)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../client_subscriptions.go} | 35 +++--- providers/azure/connection/connection.go | 6 + providers/azure/resources/advisor.go | 14 ++- providers/azure/resources/aks.go | 4 +- providers/azure/resources/authorization.go | 4 +- providers/azure/resources/cloud_defender.go | 4 +- providers/azure/resources/compute.go | 29 +++-- providers/azure/resources/cosmosdb.go | 4 +- providers/azure/resources/discovery.go | 10 +- providers/azure/resources/keyvault.go | 32 +++-- providers/azure/resources/mariadb.go | 16 ++- providers/azure/resources/monitor.go | 16 ++- providers/azure/resources/mysql.go | 32 +++-- providers/azure/resources/network.go | 112 +++++++++++++----- providers/azure/resources/postgresql.go | 16 ++- providers/azure/resources/resource_groups.go | 4 +- providers/azure/resources/resources.go | 4 +- providers/azure/resources/sql.go | 68 ++++++++--- providers/azure/resources/storage.go | 16 ++- providers/azure/resources/subscription.go | 4 +- providers/azure/resources/web.go | 28 +++-- 21 files changed, 333 insertions(+), 125 deletions(-) rename providers/azure/{resources/subscriptions.go => connection/client_subscriptions.go} (64%) diff --git a/providers/azure/resources/subscriptions.go b/providers/azure/connection/client_subscriptions.go similarity index 64% rename from providers/azure/resources/subscriptions.go rename to providers/azure/connection/client_subscriptions.go index fb925db074..a029da37a2 100644 --- a/providers/azure/resources/subscriptions.go +++ b/providers/azure/connection/client_subscriptions.go @@ -1,33 +1,38 @@ // Copyright (c) Mondoo, Inc. // SPDX-License-Identifier: BUSL-1.1 -package resources +package connection import ( "context" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" subscriptions "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armsubscriptions" ) -type subscriptionsClient struct { - token azcore.TokenCredential +type SubscriptionsFilter struct { + Exclude []string + Include []string } -type subscriptionsFilter struct { - exclude []string - include []string +type subscriptionsClient struct { + token azcore.TokenCredential + clientOptions policy.ClientOptions } -func NewSubscriptionsClient(token azcore.TokenCredential) *subscriptionsClient { +func NewSubscriptionsClient(token azcore.TokenCredential, clientOptions policy.ClientOptions) *subscriptionsClient { return &subscriptionsClient{ - token: token, + token: token, + clientOptions: clientOptions, } } -func (client *subscriptionsClient) GetSubscriptions(filter subscriptionsFilter) ([]subscriptions.Subscription, error) { - subscriptionsC, err := subscriptions.NewClient(client.token, &arm.ClientOptions{}) +func (client *subscriptionsClient) GetSubscriptions(filter SubscriptionsFilter) ([]subscriptions.Subscription, error) { + subscriptionsC, err := subscriptions.NewClient(client.token, &arm.ClientOptions{ + ClientOptions: client.clientOptions, + }) ctx := context.Background() subs := []subscriptions.Subscription{} @@ -49,10 +54,10 @@ func (client *subscriptionsClient) GetSubscriptions(filter subscriptionsFilter) return subs, nil } -func skipSub(sub *subscriptions.Subscription, filter subscriptionsFilter) bool { +func skipSub(sub *subscriptions.Subscription, filter SubscriptionsFilter) bool { // anything explicitly specified in the list of includes means accept only from that list - if len(filter.include) > 0 { - for _, s := range filter.include { + if len(filter.Include) > 0 { + for _, s := range filter.Include { if s == *sub.SubscriptionID { return false } @@ -63,8 +68,8 @@ func skipSub(sub *subscriptions.Subscription, filter subscriptionsFilter) bool { // if nothing explicitly meant to be included, then check whether // it should be excluded - if len(filter.exclude) > 0 { - for _, s := range filter.exclude { + if len(filter.Exclude) > 0 { + for _, s := range filter.Exclude { if s == *sub.SubscriptionID { return true } diff --git a/providers/azure/connection/connection.go b/providers/azure/connection/connection.go index 7b69d63f9d..8eba5d614b 100644 --- a/providers/azure/connection/connection.go +++ b/providers/azure/connection/connection.go @@ -5,6 +5,7 @@ package connection import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/pkg/errors" "go.mondoo.com/cnquery/v9/providers-sdk/v1/inventory" "go.mondoo.com/cnquery/v9/providers-sdk/v1/vault" @@ -25,6 +26,7 @@ type AzureConnection struct { token azcore.TokenCredential // note: in the future, we might make this optional if we have a tenant-level asset. subscriptionId string + clientOptions policy.ClientOptions } func NewAzureConnection(id uint32, asset *inventory.Asset, conf *inventory.Config) (*AzureConnection, error) { @@ -73,3 +75,7 @@ func (p *AzureConnection) Token() azcore.TokenCredential { func (p *AzureConnection) PlatformId() string { return "//platformid.api.mondoo.app/runtime/azure/subscriptions/" + p.subscriptionId } + +func (p *AzureConnection) ClientOptions() policy.ClientOptions { + return p.clientOptions +} diff --git a/providers/azure/resources/advisor.go b/providers/azure/resources/advisor.go index 83e866c18c..7fda7445bc 100644 --- a/providers/azure/resources/advisor.go +++ b/providers/azure/resources/advisor.go @@ -14,16 +14,16 @@ import ( "strings" "time" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + advisor "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/advisor/armadvisor" "go.mondoo.com/cnquery/v9/llx" "go.mondoo.com/cnquery/v9/providers-sdk/v1/plugin" "go.mondoo.com/cnquery/v9/providers-sdk/v1/util/convert" "go.mondoo.com/cnquery/v9/providers/azure/connection" "go.mondoo.com/cnquery/v9/types" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - advisor "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/advisor/armadvisor" ) func initAzureSubscriptionAdvisorService(runtime *plugin.Runtime, args map[string]*llx.RawData) (map[string]*llx.RawData, plugin.Resource, error) { @@ -42,7 +42,9 @@ func (a *mqlAzureSubscriptionAdvisorService) recommendations() ([]interface{}, e ctx := context.Background() token := conn.Token() subId := a.SubscriptionId.Data - client, err := advisor.NewRecommendationsClient(subId, token, nil) + client, err := advisor.NewRecommendationsClient(subId, token, &arm.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return nil, err } diff --git a/providers/azure/resources/aks.go b/providers/azure/resources/aks.go index 5cfae68447..074b90ce8f 100644 --- a/providers/azure/resources/aks.go +++ b/providers/azure/resources/aks.go @@ -40,7 +40,9 @@ func (a *mqlAzureSubscriptionAksService) clusters() ([]interface{}, error) { ctx := context.Background() token := conn.Token() subId := a.SubscriptionId.Data - client, err := clusters.NewManagedClustersClient(subId, token, &arm.ClientOptions{}) + client, err := clusters.NewManagedClustersClient(subId, token, &arm.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return nil, err } diff --git a/providers/azure/resources/authorization.go b/providers/azure/resources/authorization.go index a290f1d12c..629211b989 100644 --- a/providers/azure/resources/authorization.go +++ b/providers/azure/resources/authorization.go @@ -45,7 +45,9 @@ func (a *mqlAzureSubscriptionAuthorizationService) roleDefinitions() ([]interfac ctx := context.Background() token := conn.Token() subId := a.SubscriptionId.Data - client, err := authorization.NewRoleDefinitionsClient(token, &arm.ClientOptions{}) + client, err := authorization.NewRoleDefinitionsClient(token, &arm.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return nil, err } diff --git a/providers/azure/resources/cloud_defender.go b/providers/azure/resources/cloud_defender.go index 307c86427d..98598f68a6 100644 --- a/providers/azure/resources/cloud_defender.go +++ b/providers/azure/resources/cloud_defender.go @@ -106,7 +106,9 @@ func (a *mqlAzureSubscriptionCloudDefenderService) monitoringAgentAutoProvision( token := conn.Token() subId := a.SubscriptionId.Data - client, err := security.NewAutoProvisioningSettingsClient(subId, token, &arm.ClientOptions{}) + client, err := security.NewAutoProvisioningSettingsClient(subId, token, &arm.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return false, err } diff --git a/providers/azure/resources/compute.go b/providers/azure/resources/compute.go index 081e4f60a7..2f3200861b 100644 --- a/providers/azure/resources/compute.go +++ b/providers/azure/resources/compute.go @@ -7,7 +7,6 @@ import ( "context" "encoding/json" "errors" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" compute "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute" network "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork" @@ -41,7 +40,9 @@ func (a *mqlAzureSubscriptionComputeService) vms() ([]interface{}, error) { subId := a.SubscriptionId.Data // list compute instances - vmClient, err := compute.NewVirtualMachinesClient(subId, token, &arm.ClientOptions{}) + vmClient, err := compute.NewVirtualMachinesClient(subId, token, &arm.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return nil, err } @@ -97,7 +98,9 @@ func (a *mqlAzureSubscriptionComputeServiceVm) extensions() ([]interface{}, erro return nil, err } - client, err := compute.NewVirtualMachineExtensionsClient(resourceID.SubscriptionID, token, &arm.ClientOptions{}) + client, err := compute.NewVirtualMachineExtensionsClient(resourceID.SubscriptionID, token, &arm.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return nil, err } @@ -135,7 +138,9 @@ func (a *mqlAzureSubscriptionComputeService) disks() ([]interface{}, error) { token := conn.Token() subId := a.SubscriptionId.Data - client, err := compute.NewDisksClient(subId, token, &arm.ClientOptions{}) + client, err := compute.NewDisksClient(subId, token, &arm.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return nil, err } @@ -237,7 +242,9 @@ func (a *mqlAzureSubscriptionComputeServiceVm) osDisk() (*mqlAzureSubscriptionCo ctx := context.Background() token := conn.Token() - client, err := compute.NewDisksClient(resourceID.SubscriptionID, token, &arm.ClientOptions{}) + client, err := compute.NewDisksClient(resourceID.SubscriptionID, token, &arm.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return nil, err } @@ -288,7 +295,9 @@ func (a *mqlAzureSubscriptionComputeServiceVm) dataDisks() ([]interface{}, error return nil, err } - client, err := compute.NewDisksClient(resourceID.SubscriptionID, token, &arm.ClientOptions{}) + client, err := compute.NewDisksClient(resourceID.SubscriptionID, token, &arm.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return nil, err } @@ -347,11 +356,15 @@ func (a *mqlAzureSubscriptionComputeServiceVm) publicIpAddresses() ([]interface{ res := []interface{}{} ctx := context.Background() - nicClient, err := network.NewInterfacesClient(subId, token, &arm.ClientOptions{}) + nicClient, err := network.NewInterfacesClient(subId, token, &arm.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return nil, err } - ipClient, err := network.NewPublicIPAddressesClient(subId, token, &arm.ClientOptions{}) + ipClient, err := network.NewPublicIPAddressesClient(subId, token, &arm.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return nil, err } diff --git a/providers/azure/resources/cosmosdb.go b/providers/azure/resources/cosmosdb.go index c2581f97e3..fb0b801920 100644 --- a/providers/azure/resources/cosmosdb.go +++ b/providers/azure/resources/cosmosdb.go @@ -41,7 +41,9 @@ func (a *mqlAzureSubscriptionCosmosDbService) accounts() ([]interface{}, error) token := conn.Token() subId := a.SubscriptionId.Data - accClient, err := cosmosdb.NewDatabaseAccountsClient(subId, token, &arm.ClientOptions{}) + accClient, err := cosmosdb.NewDatabaseAccountsClient(subId, token, &arm.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return nil, err } diff --git a/providers/azure/resources/discovery.go b/providers/azure/resources/discovery.go index 1bb5b26eec..23e8be4d2f 100644 --- a/providers/azure/resources/discovery.go +++ b/providers/azure/resources/discovery.go @@ -68,12 +68,12 @@ func Discover(runtime *plugin.Runtime, rootConf *inventory.Config) (*inventory.I targets := rootConf.GetDiscover().GetTargets() subsToInclude := rootConf.Options["subscriptions"] subsToExclude := rootConf.Options["subscriptions-exclude"] - filter := subscriptionsFilter{} + filter := connection.SubscriptionsFilter{} if len(subsToInclude) > 0 { - filter.include = strings.Split(subsToInclude, ",") + filter.Include = strings.Split(subsToInclude, ",") } if len(subsToExclude) > 0 { - filter.exclude = strings.Split(subsToExclude, ",") + filter.Exclude = strings.Split(subsToExclude, ",") } // note: we always need the subscriptions, either to return them as assets or discover resources inside the subs subs, err := discoverSubscriptions(conn, filter) @@ -603,8 +603,8 @@ func getInstancesLabels(vm *mqlAzureSubscriptionComputeServiceVm) (map[string]st return labels, nil } -func discoverSubscriptions(conn *connection.AzureConnection, filter subscriptionsFilter) ([]subscriptions.Subscription, error) { - subsClient := NewSubscriptionsClient(conn.Token()) +func discoverSubscriptions(conn *connection.AzureConnection, filter connection.SubscriptionsFilter) ([]subscriptions.Subscription, error) { + subsClient := connection.NewSubscriptionsClient(conn.Token(), conn.ClientOptions()) subs, err := subsClient.GetSubscriptions(filter) if err != nil { return nil, err diff --git a/providers/azure/resources/keyvault.go b/providers/azure/resources/keyvault.go index 1b5e10f169..eb81c62dd1 100644 --- a/providers/azure/resources/keyvault.go +++ b/providers/azure/resources/keyvault.go @@ -86,7 +86,9 @@ func (a *mqlAzureSubscriptionKeyVaultService) vaults() ([]interface{}, error) { token := conn.Token() subId := a.SubscriptionId.Data - client, err := keyvault.NewVaultsClient(subId, token, &arm.ClientOptions{}) + client, err := keyvault.NewVaultsClient(subId, token, &arm.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return nil, err } @@ -137,7 +139,9 @@ func (a *mqlAzureSubscriptionKeyVaultServiceVault) properties() (interface{}, er if err != nil { return nil, err } - client, err := keyvault.NewVaultsClient(resourceID.SubscriptionID, token, &arm.ClientOptions{}) + client, err := keyvault.NewVaultsClient(resourceID.SubscriptionID, token, &arm.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return nil, err } @@ -167,7 +171,9 @@ func (a *mqlAzureSubscriptionKeyVaultServiceVault) keys() ([]interface{}, error) ctx := context.Background() token := conn.Token() vaultUri := a.GetVaultUri() - client, err := azkeys.NewClient(vaultUri.Data, token, &azkeys.ClientOptions{}) + client, err := azkeys.NewClient(vaultUri.Data, token, &azkeys.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return nil, err } @@ -207,7 +213,9 @@ func (a *mqlAzureSubscriptionKeyVaultServiceVault) secrets() ([]interface{}, err ctx := context.Background() token := conn.Token() vaultUri := a.GetVaultUri() - client, err := azsecrets.NewClient(vaultUri.Data, token, &azsecrets.ClientOptions{}) + client, err := azsecrets.NewClient(vaultUri.Data, token, &azsecrets.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return nil, err } @@ -247,7 +255,9 @@ func (a *mqlAzureSubscriptionKeyVaultServiceVault) certificates() ([]interface{} ctx := context.Background() token := conn.Token() vaultUri := a.GetVaultUri() - client, err := azcertificates.NewClient(vaultUri.Data, token, &azcertificates.ClientOptions{}) + client, err := azcertificates.NewClient(vaultUri.Data, token, &azcertificates.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return nil, err } @@ -322,7 +332,9 @@ func (a *mqlAzureSubscriptionKeyVaultServiceKey) versions() ([]interface{}, erro return nil, errors.New("only key ids are supported") } - client, err := azkeys.NewClient(kvid.BaseUrl, conn.Token(), &azkeys.ClientOptions{}) + client, err := azkeys.NewClient(kvid.BaseUrl, conn.Token(), &azkeys.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return nil, err } @@ -395,7 +407,9 @@ func (a *mqlAzureSubscriptionKeyVaultServiceCertificate) versions() ([]interface vaultUrl := kvid.BaseUrl name := kvid.Name - client, err := azcertificates.NewClient(vaultUrl, conn.Token(), &azcertificates.ClientOptions{}) + client, err := azcertificates.NewClient(vaultUrl, conn.Token(), &azcertificates.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return nil, err } @@ -469,7 +483,9 @@ func (a *mqlAzureSubscriptionKeyVaultServiceSecret) versions() ([]interface{}, e name := kvid.Name ctx := context.Background() - client, err := azsecrets.NewClient(vaultUrl, conn.Token(), &azsecrets.ClientOptions{}) + client, err := azsecrets.NewClient(vaultUrl, conn.Token(), &azsecrets.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return nil, err } diff --git a/providers/azure/resources/mariadb.go b/providers/azure/resources/mariadb.go index 7b240fc01f..f138fc6817 100644 --- a/providers/azure/resources/mariadb.go +++ b/providers/azure/resources/mariadb.go @@ -46,7 +46,9 @@ func (a *mqlAzureSubscriptionMariaDbService) servers() ([]interface{}, error) { token := conn.Token() subId := a.SubscriptionId.Data - dbClient, err := mariadb.NewServersClient(subId, token, &arm.ClientOptions{}) + dbClient, err := mariadb.NewServersClient(subId, token, &arm.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return nil, err } @@ -95,7 +97,9 @@ func (a *mqlAzureSubscriptionMariaDbServiceServer) databases() ([]interface{}, e if err != nil { return nil, err } - dbDatabaseClient, err := mariadb.NewDatabasesClient(resourceID.SubscriptionID, token, &arm.ClientOptions{}) + dbDatabaseClient, err := mariadb.NewDatabasesClient(resourceID.SubscriptionID, token, &arm.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return nil, err } @@ -140,7 +144,9 @@ func (a *mqlAzureSubscriptionMariaDbServiceServer) firewallRules() ([]interface{ return nil, err } - dbFirewallClient, err := mariadb.NewFirewallRulesClient(resourceID.SubscriptionID, token, &arm.ClientOptions{}) + dbFirewallClient, err := mariadb.NewFirewallRulesClient(resourceID.SubscriptionID, token, &arm.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return nil, err } @@ -186,7 +192,9 @@ func (a *mqlAzureSubscriptionMariaDbServiceServer) configuration() ([]interface{ return nil, err } - dbConfClient, err := mariadb.NewConfigurationsClient(resourceID.SubscriptionID, token, &arm.ClientOptions{}) + dbConfClient, err := mariadb.NewConfigurationsClient(resourceID.SubscriptionID, token, &arm.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return nil, err } diff --git a/providers/azure/resources/monitor.go b/providers/azure/resources/monitor.go index 00f2ece12a..110288bff5 100644 --- a/providers/azure/resources/monitor.go +++ b/providers/azure/resources/monitor.go @@ -79,7 +79,9 @@ func (a *mqlAzureSubscriptionMonitorService) logProfiles() ([]interface{}, error ctx := context.Background() token := conn.Token() subId := a.SubscriptionId.Data - client, err := monitor.NewLogProfilesClient(subId, token, &arm.ClientOptions{}) + client, err := monitor.NewLogProfilesClient(subId, token, &arm.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return nil, err } @@ -128,7 +130,9 @@ func (a *mqlAzureSubscriptionMonitorService) applicationInsights() ([]interface{ token := conn.Token() subId := a.SubscriptionId.Data - client, err := appinsights.NewComponentsClient(subId, token, &arm.ClientOptions{}) + client, err := appinsights.NewComponentsClient(subId, token, &arm.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return nil, err } @@ -170,7 +174,9 @@ func (a *mqlAzureSubscriptionMonitorServiceActivityLog) alerts() ([]interface{}, ctx := context.Background() token := conn.Token() subId := a.SubscriptionId.Data - client, err := monitor.NewActivityLogAlertsClient(subId, token, &arm.ClientOptions{}) + client, err := monitor.NewActivityLogAlertsClient(subId, token, &arm.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return nil, err } @@ -297,7 +303,9 @@ func (a *mqlAzureSubscriptionMonitorServiceDiagnosticsetting) storageAccount() ( func getDiagnosticSettings(id string, runtime *plugin.Runtime, conn *connection.AzureConnection) ([]interface{}, error) { ctx := context.Background() token := conn.Token() - client, err := monitor.NewDiagnosticSettingsClient(token, &arm.ClientOptions{}) + client, err := monitor.NewDiagnosticSettingsClient(token, &arm.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return nil, err } diff --git a/providers/azure/resources/mysql.go b/providers/azure/resources/mysql.go index 194d7695ac..06d3e9d5ae 100644 --- a/providers/azure/resources/mysql.go +++ b/providers/azure/resources/mysql.go @@ -52,7 +52,9 @@ func (a *mqlAzureSubscriptionMySqlService) servers() ([]interface{}, error) { token := conn.Token() subId := a.SubscriptionId.Data - dbClient, err := mysql.NewServersClient(subId, token, &arm.ClientOptions{}) + dbClient, err := mysql.NewServersClient(subId, token, &arm.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return nil, err } @@ -93,7 +95,9 @@ func (a *mqlAzureSubscriptionMySqlService) flexibleServers() ([]interface{}, err token := conn.Token() subId := a.SubscriptionId.Data - dbClient, err := flexible.NewServersClient(subId, token, &arm.ClientOptions{}) + dbClient, err := flexible.NewServersClient(subId, token, &arm.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return nil, err } @@ -143,7 +147,9 @@ func (a *mqlAzureSubscriptionMySqlServiceServer) databases() ([]interface{}, err return nil, err } - dbDatabaseClient, err := mysql.NewDatabasesClient(resourceID.SubscriptionID, token, &arm.ClientOptions{}) + dbDatabaseClient, err := mysql.NewDatabasesClient(resourceID.SubscriptionID, token, &arm.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return nil, err } @@ -188,7 +194,9 @@ func (a *mqlAzureSubscriptionMySqlServiceServer) firewallRules() ([]interface{}, return nil, err } - dbFirewallClient, err := mysql.NewFirewallRulesClient(resourceID.SubscriptionID, token, &arm.ClientOptions{}) + dbFirewallClient, err := mysql.NewFirewallRulesClient(resourceID.SubscriptionID, token, &arm.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return nil, err } @@ -233,7 +241,9 @@ func (a *mqlAzureSubscriptionMySqlServiceServer) configuration() ([]interface{}, return nil, err } - dbConfClient, err := mysql.NewConfigurationsClient(resourceID.SubscriptionID, token, &arm.ClientOptions{}) + dbConfClient, err := mysql.NewConfigurationsClient(resourceID.SubscriptionID, token, &arm.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return nil, err } @@ -281,7 +291,9 @@ func (a *mqlAzureSubscriptionMySqlServiceFlexibleServer) databases() ([]interfac return nil, err } - dbDatabaseClient, err := flexible.NewDatabasesClient(resourceID.SubscriptionID, token, &arm.ClientOptions{}) + dbDatabaseClient, err := flexible.NewDatabasesClient(resourceID.SubscriptionID, token, &arm.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return nil, err } @@ -325,7 +337,9 @@ func (a *mqlAzureSubscriptionMySqlServiceFlexibleServer) firewallRules() ([]inte if err != nil { return nil, err } - dbFirewallClient, err := flexible.NewFirewallRulesClient(resourceID.SubscriptionID, token, &arm.ClientOptions{}) + dbFirewallClient, err := flexible.NewFirewallRulesClient(resourceID.SubscriptionID, token, &arm.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return nil, err } @@ -370,7 +384,9 @@ func (a *mqlAzureSubscriptionMySqlServiceFlexibleServer) configuration() ([]inte return nil, err } - dbConfClient, err := flexible.NewConfigurationsClient(resourceID.SubscriptionID, token, &arm.ClientOptions{}) + dbConfClient, err := flexible.NewConfigurationsClient(resourceID.SubscriptionID, token, &arm.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return nil, err } diff --git a/providers/azure/resources/network.go b/providers/azure/resources/network.go index 3e7e28bce1..b8aaf6625b 100644 --- a/providers/azure/resources/network.go +++ b/providers/azure/resources/network.go @@ -41,7 +41,9 @@ func (a *mqlAzureSubscriptionNetworkService) interfaces() ([]interface{}, error) token := conn.Token() subId := a.SubscriptionId.Data - client, err := network.NewInterfacesClient(subId, token, &arm.ClientOptions{}) + client, err := network.NewInterfacesClient(subId, token, &arm.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return nil, err } @@ -72,7 +74,9 @@ func (a *mqlAzureSubscriptionNetworkService) securityGroups() ([]interface{}, er token := conn.Token() subId := a.SubscriptionId.Data - client, err := network.NewSecurityGroupsClient(subId, token, &arm.ClientOptions{}) + client, err := network.NewSecurityGroupsClient(subId, token, &arm.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return nil, err } @@ -103,7 +107,9 @@ func (a *mqlAzureSubscriptionNetworkService) watchers() ([]interface{}, error) { token := conn.Token() subId := a.SubscriptionId.Data - client, err := network.NewWatchersClient(subId, token, &arm.ClientOptions{}) + client, err := network.NewWatchersClient(subId, token, &arm.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return nil, err } @@ -147,7 +153,9 @@ func (a *mqlAzureSubscriptionNetworkService) publicIpAddresses() ([]interface{}, token := conn.Token() subId := a.SubscriptionId.Data - client, err := network.NewPublicIPAddressesClient(subId, token, &arm.ClientOptions{}) + client, err := network.NewPublicIPAddressesClient(subId, token, &arm.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return nil, err } @@ -178,7 +186,9 @@ func (a *mqlAzureSubscriptionNetworkService) bastionHosts() ([]interface{}, erro token := conn.Token() subId := a.SubscriptionId.Data - client, err := network.NewBastionHostsClient(subId, token, &arm.ClientOptions{}) + client, err := network.NewBastionHostsClient(subId, token, &arm.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return nil, err } @@ -233,7 +243,9 @@ func (a *mqlAzureSubscriptionNetworkServiceWatcher) flowLogs() ([]interface{}, e return nil, err } subId := resourceID.SubscriptionID - client, err := network.NewFlowLogsClient(subId, token, &arm.ClientOptions{}) + client, err := network.NewFlowLogsClient(subId, token, &arm.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return nil, err } @@ -309,7 +321,9 @@ func (a *mqlAzureSubscriptionNetworkService) loadBalancers() ([]interface{}, err token := conn.Token() subId := a.SubscriptionId.Data - client, err := network.NewLoadBalancersClient(subId, token, &arm.ClientOptions{}) + client, err := network.NewLoadBalancersClient(subId, token, &arm.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return nil, err } @@ -499,7 +513,9 @@ func (a *mqlAzureSubscriptionNetworkService) natGateways() ([]interface{}, error token := conn.Token() subId := a.SubscriptionId.Data - client, err := network.NewNatGatewaysClient(subId, token, &arm.ClientOptions{}) + client, err := network.NewNatGatewaysClient(subId, token, &arm.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return nil, err } @@ -529,7 +545,9 @@ func (a *mqlAzureSubscriptionNetworkService) firewalls() ([]interface{}, error) ctx := context.Background() token := conn.Token() subId := a.SubscriptionId.Data - client, err := network.NewAzureFirewallsClient(subId, token, &arm.ClientOptions{}) + client, err := network.NewAzureFirewallsClient(subId, token, &arm.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return nil, err } @@ -572,7 +590,9 @@ func (a *mqlAzureSubscriptionNetworkServiceFirewall) policy() (*mqlAzureSubscrip if err != nil { return nil, err } - client, err := network.NewFirewallPoliciesClient(azureId.SubscriptionID, token, &arm.ClientOptions{}) + client, err := network.NewFirewallPoliciesClient(azureId.SubscriptionID, token, &arm.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return nil, err } @@ -608,7 +628,9 @@ func (a *mqlAzureSubscriptionNetworkServiceFirewallIpConfig) publicIpAddress() ( if err != nil { return nil, err } - client, err := network.NewPublicIPAddressesClient(azureId.SubscriptionID, token, &arm.ClientOptions{}) + client, err := network.NewPublicIPAddressesClient(azureId.SubscriptionID, token, &arm.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return nil, err } @@ -644,7 +666,9 @@ func (a *mqlAzureSubscriptionNetworkServiceVirtualNetworkGatewayIpConfig) public if err != nil { return nil, err } - client, err := network.NewPublicIPAddressesClient(azureId.SubscriptionID, token, &arm.ClientOptions{}) + client, err := network.NewPublicIPAddressesClient(azureId.SubscriptionID, token, &arm.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return nil, err } @@ -680,7 +704,9 @@ func (a *mqlAzureSubscriptionNetworkServiceFirewallIpConfig) subnet() (*mqlAzure if err != nil { return nil, err } - client, err := network.NewSubnetsClient(azureId.SubscriptionID, token, &arm.ClientOptions{}) + client, err := network.NewSubnetsClient(azureId.SubscriptionID, token, &arm.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return nil, err } @@ -707,7 +733,9 @@ func (a *mqlAzureSubscriptionNetworkService) firewallPolicies() ([]interface{}, ctx := context.Background() token := conn.Token() subId := a.SubscriptionId.Data - client, err := network.NewFirewallPoliciesClient(subId, token, &arm.ClientOptions{}) + client, err := network.NewFirewallPoliciesClient(subId, token, &arm.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return nil, err } @@ -738,7 +766,9 @@ func (a *mqlAzureSubscriptionNetworkService) virtualNetworks() ([]interface{}, e token := conn.Token() subId := a.SubscriptionId.Data - client, err := network.NewVirtualNetworksClient(subId, token, &arm.ClientOptions{}) + client, err := network.NewVirtualNetworksClient(subId, token, &arm.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return nil, err } @@ -808,7 +838,9 @@ func (a *mqlAzureSubscriptionNetworkService) applicationSecurityGroups() ([]inte token := conn.Token() subId := a.SubscriptionId.Data - client, err := network.NewApplicationSecurityGroupsClient(subId, token, &arm.ClientOptions{}) + client, err := network.NewApplicationSecurityGroupsClient(subId, token, &arm.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return nil, err } @@ -850,7 +882,9 @@ func (a *mqlAzureSubscriptionNetworkService) virtualNetworkGateways() ([]interfa token := conn.Token() subId := a.SubscriptionId.Data - client, err := network.NewVirtualNetworkGatewaysClient(subId, token, &arm.ClientOptions{}) + client, err := network.NewVirtualNetworkGatewaysClient(subId, token, &arm.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return nil, err } @@ -1002,7 +1036,9 @@ func (a *mqlAzureSubscriptionNetworkService) applicationGateways() ([]interface{ token := conn.Token() subId := a.SubscriptionId.Data - client, err := network.NewApplicationGatewaysClient(subId, token, &arm.ClientOptions{}) + client, err := network.NewApplicationGatewaysClient(subId, token, &arm.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return nil, err } @@ -1033,7 +1069,9 @@ func (a *mqlAzureSubscriptionNetworkService) applicationFirewallPolicies() ([]in token := conn.Token() subId := a.SubscriptionId.Data - client, err := network.NewWebApplicationFirewallPoliciesClient(subId, token, &arm.ClientOptions{}) + client, err := network.NewWebApplicationFirewallPoliciesClient(subId, token, &arm.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return nil, err } @@ -1080,7 +1118,9 @@ func (a *mqlAzureSubscriptionNetworkServiceApplicationGateway) policy() (*mqlAzu conn := a.MqlRuntime.Connection.(*connection.AzureConnection) ctx := context.Background() token := conn.Token() - client, err := network.NewWebApplicationFirewallPoliciesClient(azureId.SubscriptionID, token, &arm.ClientOptions{}) + client, err := network.NewWebApplicationFirewallPoliciesClient(azureId.SubscriptionID, token, &arm.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return nil, err } @@ -1108,7 +1148,9 @@ func (a *mqlAzureSubscriptionNetworkServiceApplicationFirewallPolicy) gateways() conn := a.MqlRuntime.Connection.(*connection.AzureConnection) ctx := context.Background() token := conn.Token() - client, err := network.NewApplicationGatewaysClient(conn.SubId(), token, &arm.ClientOptions{}) + client, err := network.NewApplicationGatewaysClient(conn.SubId(), token, &arm.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return nil, err } @@ -1157,7 +1199,9 @@ func (a *mqlAzureSubscriptionNetworkServiceNatGateway) publicIpAddresses() ([]in } res := []interface{}{} - client, err := network.NewPublicIPAddressesClient(azureId.SubscriptionID, token, &arm.ClientOptions{}) + client, err := network.NewPublicIPAddressesClient(azureId.SubscriptionID, token, &arm.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return nil, err } @@ -1195,7 +1239,9 @@ func (a *mqlAzureSubscriptionNetworkServiceVirtualNetworkGateway) connections() if err != nil { return nil, err } - client, err := network.NewVirtualNetworkGatewayConnectionsClient(azureId.SubscriptionID, token, &arm.ClientOptions{}) + client, err := network.NewVirtualNetworkGatewayConnectionsClient(azureId.SubscriptionID, token, &arm.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return nil, err } @@ -1260,7 +1306,9 @@ func (a *mqlAzureSubscriptionNetworkServiceNatGateway) subnets() ([]interface{}, return nil, nil } res := []interface{}{} - client, err := network.NewSubnetsClient(azureId.SubscriptionID, token, &arm.ClientOptions{}) + client, err := network.NewSubnetsClient(azureId.SubscriptionID, token, &arm.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return nil, err } @@ -1318,7 +1366,9 @@ func (a *mqlAzureSubscriptionNetworkServiceSubnet) natGateway() (*mqlAzureSubscr if err != nil { return nil, err } - client, err := network.NewNatGatewaysClient(azureId.SubscriptionID, token, &arm.ClientOptions{}) + client, err := network.NewNatGatewaysClient(azureId.SubscriptionID, token, &arm.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return nil, err } @@ -1397,7 +1447,9 @@ func (a *mqlAzureSubscriptionNetworkServiceFirewallPolicy) basePolicy() (*mqlAzu if err != nil { return nil, err } - client, err := network.NewFirewallPoliciesClient(resourceID.SubscriptionID, token, &arm.ClientOptions{}) + client, err := network.NewFirewallPoliciesClient(resourceID.SubscriptionID, token, &arm.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return nil, err } @@ -1427,7 +1479,9 @@ func (a *mqlAzureSubscriptionNetworkServiceFirewallPolicy) childPolicies() ([]in return nil, err } - client, err := network.NewFirewallPoliciesClient(baseResourceId.SubscriptionID, token, &arm.ClientOptions{}) + client, err := network.NewFirewallPoliciesClient(baseResourceId.SubscriptionID, token, &arm.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return nil, err } @@ -1472,7 +1526,9 @@ func (a *mqlAzureSubscriptionNetworkServiceFirewallPolicy) firewalls() ([]interf return nil, err } - client, err := network.NewAzureFirewallsClient(baseResourceId.SubscriptionID, token, &arm.ClientOptions{}) + client, err := network.NewAzureFirewallsClient(baseResourceId.SubscriptionID, token, &arm.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return nil, err } diff --git a/providers/azure/resources/postgresql.go b/providers/azure/resources/postgresql.go index 460ed65adb..90cc13bb43 100644 --- a/providers/azure/resources/postgresql.go +++ b/providers/azure/resources/postgresql.go @@ -47,7 +47,9 @@ func (a *mqlAzureSubscriptionPostgreSqlService) servers() ([]interface{}, error) token := conn.Token() subId := a.SubscriptionId.Data - dbClient, err := postgresql.NewServersClient(subId, token, &arm.ClientOptions{}) + dbClient, err := postgresql.NewServersClient(subId, token, &arm.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return nil, err } @@ -106,7 +108,9 @@ func (a *mqlAzureSubscriptionPostgreSqlServiceServer) databases() ([]interface{} return nil, err } - dbDatabaseClient, err := postgresql.NewDatabasesClient(resourceID.SubscriptionID, token, &arm.ClientOptions{}) + dbDatabaseClient, err := postgresql.NewDatabasesClient(resourceID.SubscriptionID, token, &arm.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return nil, &json.MarshalerError{} } @@ -150,7 +154,9 @@ func (a *mqlAzureSubscriptionPostgreSqlServiceServer) firewallRules() ([]interfa if err != nil { return nil, err } - dbFirewallClient, err := postgresql.NewFirewallRulesClient(resourceID.SubscriptionID, token, &arm.ClientOptions{}) + dbFirewallClient, err := postgresql.NewFirewallRulesClient(resourceID.SubscriptionID, token, &arm.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return nil, err } @@ -194,7 +200,9 @@ func (a *mqlAzureSubscriptionPostgreSqlServiceServer) configuration() ([]interfa if err != nil { return nil, err } - dbConfClient, err := postgresql.NewConfigurationsClient(resourceID.SubscriptionID, token, &arm.ClientOptions{}) + dbConfClient, err := postgresql.NewConfigurationsClient(resourceID.SubscriptionID, token, &arm.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return nil, err } diff --git a/providers/azure/resources/resource_groups.go b/providers/azure/resources/resource_groups.go index b1a871bf05..31b22b4a0f 100644 --- a/providers/azure/resources/resource_groups.go +++ b/providers/azure/resources/resource_groups.go @@ -22,7 +22,9 @@ func (a *mqlAzureSubscription) resourceGroups() ([]interface{}, error) { token := conn.Token() subId := a.SubscriptionId.Data - client, err := azureres.NewResourceGroupsClient(subId, token, &arm.ClientOptions{}) + client, err := azureres.NewResourceGroupsClient(subId, token, &arm.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return nil, err } diff --git a/providers/azure/resources/resources.go b/providers/azure/resources/resources.go index 3f75c821b8..1a19b64556 100644 --- a/providers/azure/resources/resources.go +++ b/providers/azure/resources/resources.go @@ -22,7 +22,9 @@ func (a *mqlAzureSubscription) resources() ([]interface{}, error) { token := conn.Token() subId := a.SubscriptionId.Data - client, err := azureres.NewClient(subId, token, &arm.ClientOptions{}) + client, err := azureres.NewClient(subId, token, &arm.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return nil, err } diff --git a/providers/azure/resources/sql.go b/providers/azure/resources/sql.go index daf8a23291..9affd42440 100644 --- a/providers/azure/resources/sql.go +++ b/providers/azure/resources/sql.go @@ -61,7 +61,9 @@ func (a *mqlAzureSubscriptionSqlService) servers() ([]interface{}, error) { ctx := context.Background() token := conn.Token() subId := a.SubscriptionId.Data - dbClient, err := sql.NewServersClient(subId, token, &arm.ClientOptions{}) + dbClient, err := sql.NewServersClient(subId, token, &arm.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return nil, err } @@ -111,7 +113,9 @@ func (a *mqlAzureSubscriptionSqlServiceServer) databases() ([]interface{}, error if err != nil { return nil, err } - dbDatabaseClient, err := sql.NewDatabasesClient(resourceID.SubscriptionID, token, &arm.ClientOptions{}) + dbDatabaseClient, err := sql.NewDatabasesClient(resourceID.SubscriptionID, token, &arm.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return nil, err } @@ -174,7 +178,9 @@ func (a *mqlAzureSubscriptionSqlServiceServer) firewallRules() ([]interface{}, e return nil, err } - dbFirewallClient, err := sql.NewFirewallRulesClient(resourceID.SubscriptionID, token, &arm.ClientOptions{}) + dbFirewallClient, err := sql.NewFirewallRulesClient(resourceID.SubscriptionID, token, &arm.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return nil, err } @@ -219,7 +225,9 @@ func (a *mqlAzureSubscriptionSqlServiceServer) virtualNetworkRules() ([]interfac return nil, err } - client, err := sql.NewVirtualNetworkRulesClient(resourceID.SubscriptionID, token, &arm.ClientOptions{}) + client, err := sql.NewVirtualNetworkRulesClient(resourceID.SubscriptionID, token, &arm.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return nil, err } @@ -268,7 +276,9 @@ func (a *mqlAzureSubscriptionSqlServiceServer) azureAdAdministrators() ([]interf if err != nil { return nil, err } - administratorClient, err := sql.NewServerAzureADAdministratorsClient(resourceID.SubscriptionID, token, &arm.ClientOptions{}) + administratorClient, err := sql.NewServerAzureADAdministratorsClient(resourceID.SubscriptionID, token, &arm.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return nil, err } @@ -315,7 +325,9 @@ func (a *mqlAzureSubscriptionSqlServiceServer) connectionPolicy() (interface{}, return nil, err } - connectionClient, err := sql.NewServerConnectionPoliciesClient(resourceID.SubscriptionID, token, &arm.ClientOptions{}) + connectionClient, err := sql.NewServerConnectionPoliciesClient(resourceID.SubscriptionID, token, &arm.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return nil, err } @@ -342,7 +354,9 @@ func (a *mqlAzureSubscriptionSqlServiceServer) securityAlertPolicy() (interface{ return nil, err } - secAlertClient, err := sql.NewServerSecurityAlertPoliciesClient(resourceID.SubscriptionID, token, &arm.ClientOptions{}) + secAlertClient, err := sql.NewServerSecurityAlertPoliciesClient(resourceID.SubscriptionID, token, &arm.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return nil, err } @@ -368,7 +382,9 @@ func (a *mqlAzureSubscriptionSqlServiceServer) auditingPolicy() (interface{}, er if err != nil { return nil, err } - auditClient, err := sql.NewServerBlobAuditingPoliciesClient(resourceID.SubscriptionID, token, &arm.ClientOptions{}) + auditClient, err := sql.NewServerBlobAuditingPoliciesClient(resourceID.SubscriptionID, token, &arm.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return nil, err } @@ -395,7 +411,9 @@ func (a *mqlAzureSubscriptionSqlServiceServer) threatDetectionPolicy() (interfac return nil, err } - serverClient, err := sql.NewServerAdvancedThreatProtectionSettingsClient(resourceID.SubscriptionID, token, &arm.ClientOptions{}) + serverClient, err := sql.NewServerAdvancedThreatProtectionSettingsClient(resourceID.SubscriptionID, token, &arm.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return nil, err } @@ -422,7 +440,9 @@ func (a *mqlAzureSubscriptionSqlServiceServer) encryptionProtector() (interface{ return nil, err } - client, err := sql.NewEncryptionProtectorsClient(resourceID.SubscriptionID, token, &arm.ClientOptions{}) + client, err := sql.NewEncryptionProtectorsClient(resourceID.SubscriptionID, token, &arm.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return nil, err } @@ -448,7 +468,9 @@ func (a *mqlAzureSubscriptionSqlServiceServer) vulnerabilityAssessmentSettings() return nil, err } - serverClient, err := sql.NewServerVulnerabilityAssessmentsClient(resourceID.SubscriptionID, token, &arm.ClientOptions{}) + serverClient, err := sql.NewServerVulnerabilityAssessmentsClient(resourceID.SubscriptionID, token, &arm.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return nil, err } @@ -494,7 +516,9 @@ func (a *mqlAzureSubscriptionSqlServiceDatabase) transparentDataEncryption() (in return nil, err } - client, err := sql.NewTransparentDataEncryptionsClient(resourceID.SubscriptionID, token, &arm.ClientOptions{}) + client, err := sql.NewTransparentDataEncryptionsClient(resourceID.SubscriptionID, token, &arm.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return nil, err } @@ -526,7 +550,9 @@ func (a *mqlAzureSubscriptionSqlServiceDatabase) advisor() ([]interface{}, error if err != nil { return nil, err } - client, err := sql.NewDatabaseAdvisorsClient(resourceID.SubscriptionID, token, &arm.ClientOptions{}) + client, err := sql.NewDatabaseAdvisorsClient(resourceID.SubscriptionID, token, &arm.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return nil, err } @@ -570,7 +596,9 @@ func (a *mqlAzureSubscriptionSqlServiceDatabase) threatDetectionPolicy() (interf if err != nil { return nil, err } - client, err := sql.NewDatabaseSecurityAlertPoliciesClient(resourceID.SubscriptionID, token, &arm.ClientOptions{}) + client, err := sql.NewDatabaseSecurityAlertPoliciesClient(resourceID.SubscriptionID, token, &arm.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return nil, err } @@ -598,7 +626,9 @@ func (a *mqlAzureSubscriptionSqlServiceDatabase) connectionPolicy() (interface{} return nil, err } - connectionClient, err := sql.NewServerConnectionPoliciesClient(resourceID.SubscriptionID, token, &arm.ClientOptions{}) + connectionClient, err := sql.NewServerConnectionPoliciesClient(resourceID.SubscriptionID, token, &arm.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return nil, err } @@ -630,7 +660,9 @@ func (a *mqlAzureSubscriptionSqlServiceDatabase) auditingPolicy() (interface{}, return nil, err } - auditClient, err := sql.NewDatabaseBlobAuditingPoliciesClient(resourceID.SubscriptionID, token, &arm.ClientOptions{}) + auditClient, err := sql.NewDatabaseBlobAuditingPoliciesClient(resourceID.SubscriptionID, token, &arm.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return nil, err } @@ -663,7 +695,9 @@ func (a *mqlAzureSubscriptionSqlServiceDatabase) usage() ([]interface{}, error) return nil, err } - client, err := sql.NewDatabaseUsagesClient(resourceID.SubscriptionID, token, &arm.ClientOptions{}) + client, err := sql.NewDatabaseUsagesClient(resourceID.SubscriptionID, token, &arm.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return nil, err } diff --git a/providers/azure/resources/storage.go b/providers/azure/resources/storage.go index 9e31d62474..d80f435470 100644 --- a/providers/azure/resources/storage.go +++ b/providers/azure/resources/storage.go @@ -76,7 +76,9 @@ func (a *mqlAzureSubscriptionStorageService) accounts() ([]interface{}, error) { token := conn.Token() subId := a.SubscriptionId.Data - client, err := storage.NewAccountsClient(subId, token, &arm.ClientOptions{}) + client, err := storage.NewAccountsClient(subId, token, &arm.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return nil, err } @@ -114,7 +116,9 @@ func (a *mqlAzureSubscriptionStorageServiceAccount) containers() ([]interface{}, if err != nil { return nil, err } - client, err := storage.NewBlobContainersClient(resourceID.SubscriptionID, token, &arm.ClientOptions{}) + client, err := storage.NewBlobContainersClient(resourceID.SubscriptionID, token, &arm.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return nil, err } @@ -192,7 +196,9 @@ func (a *mqlAzureSubscriptionStorageServiceAccount) dataProtection() (*mqlAzureS if err != nil { return nil, err } - client, err := storage.NewBlobServicesClient(resourceID.SubscriptionID, token, &arm.ClientOptions{}) + client, err := storage.NewBlobServicesClient(resourceID.SubscriptionID, token, &arm.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return nil, err } @@ -382,7 +388,9 @@ func storageAccountToMql(runtime *plugin.Runtime, account *storage.Account) (*mq } func getStorageAccount(id string, runtime *plugin.Runtime, azureConnection *connection.AzureConnection) (*mqlAzureSubscriptionStorageServiceAccount, error) { - client, err := storage.NewAccountsClient(azureConnection.SubId(), azureConnection.Token(), &arm.ClientOptions{}) + client, err := storage.NewAccountsClient(azureConnection.SubId(), azureConnection.Token(), &arm.ClientOptions{ + ClientOptions: azureConnection.ClientOptions(), + }) if err != nil { return nil, err } diff --git a/providers/azure/resources/subscription.go b/providers/azure/resources/subscription.go index 5433d9d8b4..20261bc442 100644 --- a/providers/azure/resources/subscription.go +++ b/providers/azure/resources/subscription.go @@ -24,7 +24,9 @@ func initAzureSubscription(runtime *plugin.Runtime, args map[string]*llx.RawData conn := runtime.Connection.(*connection.AzureConnection) - subscriptionsC, err := subscriptions.NewClient(conn.Token(), &arm.ClientOptions{}) + subscriptionsC, err := subscriptions.NewClient(conn.Token(), &arm.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return nil, nil, err } diff --git a/providers/azure/resources/web.go b/providers/azure/resources/web.go index f898aed827..c32675d40f 100644 --- a/providers/azure/resources/web.go +++ b/providers/azure/resources/web.go @@ -85,7 +85,9 @@ func (a *mqlAzureSubscriptionWebService) apps() ([]interface{}, error) { ctx := context.Background() token := conn.Token() subId := a.SubscriptionId.Data - client, err := web.NewWebAppsClient(subId, token, &arm.ClientOptions{}) + client, err := web.NewWebAppsClient(subId, token, &arm.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return nil, err } @@ -133,7 +135,9 @@ func (a *mqlAzureSubscriptionWebService) availableRuntimes() ([]interface{}, err ctx := context.Background() token := conn.Token() subId := a.SubscriptionId.Data - client, err := web.NewProviderClient(subId, token, &arm.ClientOptions{}) + client, err := web.NewProviderClient(subId, token, &arm.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return nil, err } @@ -265,7 +269,9 @@ func (a *mqlAzureSubscriptionWebServiceAppsite) configuration() (*mqlAzureSubscr return nil, err } - client, err := web.NewWebAppsClient(resourceID.SubscriptionID, token, &arm.ClientOptions{}) + client, err := web.NewWebAppsClient(resourceID.SubscriptionID, token, &arm.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return nil, err } @@ -312,7 +318,9 @@ func (a *mqlAzureSubscriptionWebServiceAppsite) authenticationSettings() (*mqlAz return nil, err } - client, err := web.NewWebAppsClient(resourceID.SubscriptionID, token, &arm.ClientOptions{}) + client, err := web.NewWebAppsClient(resourceID.SubscriptionID, token, &arm.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return nil, err } @@ -357,7 +365,9 @@ func (a *mqlAzureSubscriptionWebServiceAppsite) metadata() (interface{}, error) return nil, err } - client, err := web.NewWebAppsClient(resourceID.SubscriptionID, token, &arm.ClientOptions{}) + client, err := web.NewWebAppsClient(resourceID.SubscriptionID, token, &arm.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return nil, err } @@ -392,7 +402,9 @@ func (a *mqlAzureSubscriptionWebServiceAppsite) connectionSettings() (interface{ return nil, err } - client, err := web.NewWebAppsClient(resourceID.SubscriptionID, token, &arm.ClientOptions{}) + client, err := web.NewWebAppsClient(resourceID.SubscriptionID, token, &arm.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return nil, err } @@ -561,7 +573,9 @@ func (a *mqlAzureSubscriptionWebServiceAppsite) applicationSettings() (interface return nil, err } - client, err := web.NewWebAppsClient(resourceID.SubscriptionID, token, &arm.ClientOptions{}) + client, err := web.NewWebAppsClient(resourceID.SubscriptionID, token, &arm.ClientOptions{ + ClientOptions: conn.ClientOptions(), + }) if err != nil { return nil, err }