Files
Sergey Kostrukov 40152922d3 Azure Monitor: support AzureCredentials in common format on backend (#77424)
* Use GetDefaultCloud from SDK

* Use GetAzureCloud from SDK

* Credentials parser moved to azmoncredentials

* Refactor legacy credentials

* Tests

* Fix test description

Co-authored-by: Andreas Christou <andreas.christou@grafana.com>

---------

Co-authored-by: Andreas Christou <andreas.christou@grafana.com>
2023-11-15 14:59:23 +00:00

17 lines
554 B
Go

package azmoncredentials
import (
"github.com/grafana/grafana-azure-sdk-go/azcredentials"
"github.com/grafana/grafana-azure-sdk-go/azsettings"
)
func GetDefaultCredentials(settings *azsettings.AzureSettings) azcredentials.AzureCredentials {
if settings.ManagedIdentityEnabled {
return &azcredentials.AzureManagedIdentityCredentials{}
} else if settings.WorkloadIdentityEnabled {
return &azcredentials.AzureWorkloadIdentityCredentials{}
} else {
return &azcredentials.AzureClientSecretCredentials{AzureCloud: settings.GetDefaultCloud()}
}
}