mirror of
https://github.com/grafana/grafana.git
synced 2024-11-25 18:30:41 -06:00
81ad9769fa
* Azure cloud settings * Fix typos * Grouped Azure settings * Doc fixes * Some settings are not needed * Updated cloud name aliases
63 lines
1.3 KiB
Go
63 lines
1.3 KiB
Go
package setting
|
|
|
|
import "strings"
|
|
|
|
const (
|
|
AzurePublic = "AzureCloud"
|
|
AzureChina = "AzureChinaCloud"
|
|
AzureUSGovernment = "AzureUSGovernment"
|
|
AzureGermany = "AzureGermanCloud"
|
|
)
|
|
|
|
type AzureSettings struct {
|
|
Cloud string
|
|
ManagedIdentityEnabled bool
|
|
ManagedIdentityClientId string
|
|
}
|
|
|
|
func (cfg *Cfg) readAzureSettings() {
|
|
azureSection := cfg.Raw.Section("azure")
|
|
|
|
// Cloud
|
|
cloudName := azureSection.Key("cloud").MustString(AzurePublic)
|
|
cfg.Azure.Cloud = normalizeAzureCloud(cloudName)
|
|
|
|
// Managed Identity
|
|
cfg.Azure.ManagedIdentityEnabled = azureSection.Key("managed_identity_enabled").MustBool(false)
|
|
cfg.Azure.ManagedIdentityClientId = azureSection.Key("managed_identity_client_id").String()
|
|
}
|
|
|
|
func normalizeAzureCloud(cloudName string) string {
|
|
switch strings.ToLower(cloudName) {
|
|
// Public
|
|
case "azurecloud":
|
|
case "azurepublic":
|
|
case "azurepubliccloud":
|
|
case "public":
|
|
return AzurePublic
|
|
|
|
// China
|
|
case "azurechina":
|
|
case "azurechinacloud":
|
|
case "china":
|
|
return AzureChina
|
|
|
|
// US Government
|
|
case "azureusgovernment":
|
|
case "azureusgovernmentcloud":
|
|
case "usgov":
|
|
case "usgovernment":
|
|
return AzureUSGovernment
|
|
|
|
// Germany
|
|
case "azuregermancloud":
|
|
case "azuregermany":
|
|
case "german":
|
|
case "germany":
|
|
return AzureGermany
|
|
}
|
|
|
|
// Pass the name unchanged if it's not known
|
|
return cloudName
|
|
}
|