AzureMonitor: Azure settings in Grafana server config (#33728)
* Azure cloud settings * Fix typos * Grouped Azure settings * Doc fixes * Some settings are not needed * Updated cloud name aliases
This commit is contained in:
@@ -284,6 +284,9 @@ type Cfg struct {
|
||||
AWSAssumeRoleEnabled bool
|
||||
AWSListMetricsPageLimit int
|
||||
|
||||
// Azure Cloud settings
|
||||
Azure AzureSettings
|
||||
|
||||
// Auth proxy settings
|
||||
AuthProxyEnabled bool
|
||||
AuthProxyHeaderName string
|
||||
@@ -900,6 +903,7 @@ func (cfg *Cfg) Load(args *CommandLineArgs) error {
|
||||
|
||||
cfg.readLDAPConfig()
|
||||
cfg.handleAWSConfig()
|
||||
cfg.readAzureSettings()
|
||||
cfg.readSessionConfig()
|
||||
cfg.readSmtpSettings()
|
||||
cfg.readQuotaSettings()
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user