From 4d959955d3851afd9f4d30cf28e1e7da3fd49b6b Mon Sep 17 00:00:00 2001 From: Maxim Ivanov Date: Wed, 5 Jun 2024 11:27:10 +0000 Subject: [PATCH] Update plugins/inputs/azure_monitor/azure_monitor.go Co-authored-by: Sven Rebhan <36194019+srebhan@users.noreply.github.com> --- plugins/inputs/azure_monitor/azure_monitor.go | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/plugins/inputs/azure_monitor/azure_monitor.go b/plugins/inputs/azure_monitor/azure_monitor.go index 984c33de6a798..86da14227acc5 100644 --- a/plugins/inputs/azure_monitor/azure_monitor.go +++ b/plugins/inputs/azure_monitor/azure_monitor.go @@ -160,20 +160,16 @@ func (acm *azureClientsManager) createAzureClients( clientID string, clientSecret string, tenantID string, -) (azureClients *receiver.AzureClients, err error) { - var token azcore.TokenCredential +) (*receiver.AzureClients, error) { if clientSecret != "" { - azureClients, err = receiver.CreateAzureClients(subscriptionID, clientID, clientSecret, tenantID) - } else { - if token, err = azidentity.NewDefaultAzureCredential(&azidentity.DefaultAzureCredentialOptions{ - TenantID: tenantID, - }); err == nil { - azureClients, err = receiver.CreateAzureClientsWithCreds(subscriptionID, token) - } + return receiver.CreateAzureClients(subscriptionID, clientID, clientSecret, tenantID) } + + token, err := azidentity.NewDefaultAzureCredential(&azidentity.DefaultAzureCredentialOptions{TenantID: tenantID}) if err != nil { - return nil, fmt.Errorf("error creating Azure clients: %w", err) + return nil, fmt.Errorf("error creating Azure token: %w", err) } + return receiver.CreateAzureClientsWithCreds(subscriptionID, token) return azureClients, nil }