AzureMonitor: Update SDK version (#60372)

This commit is contained in:
Andres Martinez Gotor
2022-12-20 16:20:31 +01:00
committed by GitHub
parent ec45c9c990
commit 10cfc27397
7 changed files with 33 additions and 23 deletions
+4 -5
View File
@@ -44,7 +44,10 @@ func getAuthType(cfg *setting.Cfg, jsonData *simplejson.Json) string {
func getDefaultAzureCloud(cfg *setting.Cfg) (string, error) {
// Allow only known cloud names
cloudName := cfg.Azure.Cloud
cloudName := ""
if cfg != nil && cfg.Azure != nil {
cloudName = cfg.Azure.Cloud
}
switch cloudName {
case azsettings.AzurePublic:
return azsettings.AzurePublic, nil
@@ -52,8 +55,6 @@ func getDefaultAzureCloud(cfg *setting.Cfg) (string, error) {
return azsettings.AzureChina, nil
case azsettings.AzureUSGovernment:
return azsettings.AzureUSGovernment, nil
case azsettings.AzureGermany:
return azsettings.AzureGermany, nil
case azsettings.AzureCustomized:
return azsettings.AzureCustomized, nil
case "":
@@ -73,8 +74,6 @@ func normalizeAzureCloud(cloudName string) (string, error) {
return azsettings.AzureChina, nil
case azureMonitorUSGovernment:
return azsettings.AzureUSGovernment, nil
case azureMonitorGermany:
return azsettings.AzureGermany, nil
case azureMonitorCustomized:
return azsettings.AzureCustomized, nil
default:
+4 -4
View File
@@ -116,13 +116,13 @@ func TestCredentials_getAzureCloud(t *testing.T) {
t.Run("should be from datasource value normalized to known cloud name", func(t *testing.T) {
jsonData := simplejson.NewFromAny(map[string]interface{}{
"azureAuthType": azcredentials.AzureAuthClientSecret,
"cloudName": azureMonitorGermany,
"cloudName": azureMonitorUSGovernment,
})
cloud, err := getAzureCloud(cfg, jsonData)
require.NoError(t, err)
assert.Equal(t, azsettings.AzureGermany, cloud)
assert.Equal(t, azsettings.AzureUSGovernment, cloud)
})
t.Run("should be from server configuration if not set in datasource", func(t *testing.T) {
@@ -172,7 +172,7 @@ func TestCredentials_getAzureCredentials(t *testing.T) {
t.Run("when auth type is client secret", func(t *testing.T) {
jsonData := simplejson.NewFromAny(map[string]interface{}{
"azureAuthType": azcredentials.AzureAuthClientSecret,
"cloudName": azureMonitorGermany,
"cloudName": azUSGovManagement,
"tenantId": "9b9d90ee-a5cc-49c2-b97e-0d1b0f086b5c",
"clientId": "849ccbb0-92eb-4226-b228-ef391abd8fe6",
})
@@ -189,7 +189,7 @@ func TestCredentials_getAzureCredentials(t *testing.T) {
require.IsType(t, &azcredentials.AzureClientSecretCredentials{}, credentials)
clientSecretCredentials := credentials.(*azcredentials.AzureClientSecretCredentials)
assert.Equal(t, azsettings.AzureGermany, clientSecretCredentials.AzureCloud)
assert.Equal(t, azsettings.AzureChina, clientSecretCredentials.AzureCloud)
assert.Equal(t, "9b9d90ee-a5cc-49c2-b97e-0d1b0f086b5c", clientSecretCredentials.TenantId)
assert.Equal(t, "849ccbb0-92eb-4226-b228-ef391abd8fe6", clientSecretCredentials.ClientId)
assert.Equal(t, "59e3498f-eb12-4943-b8f0-a5aa42640058", clientSecretCredentials.ClientSecret)
@@ -277,8 +277,6 @@ func GetAzurePortalUrl(azureCloud string) (string, error) {
return "https://portal.azure.cn", nil
case azsettings.AzureUSGovernment:
return "https://portal.azure.us", nil
case azsettings.AzureGermany:
return "https://portal.microsoftazure.de", nil
default:
return "", fmt.Errorf("the cloud is not supported")
}
@@ -141,12 +141,11 @@ func TestAddConfigData(t *testing.T) {
}
func TestGetAzurePortalUrl(t *testing.T) {
clouds := []string{azsettings.AzurePublic, azsettings.AzureChina, azsettings.AzureUSGovernment, azsettings.AzureGermany}
clouds := []string{azsettings.AzurePublic, azsettings.AzureChina, azsettings.AzureUSGovernment}
expectedAzurePortalUrl := map[string]interface{}{
azsettings.AzurePublic: "https://portal.azure.com",
azsettings.AzureChina: "https://portal.azure.cn",
azsettings.AzureUSGovernment: "https://portal.azure.us",
azsettings.AzureGermany: "https://portal.microsoftazure.de",
}
for _, cloud := range clouds {
-3
View File
@@ -69,9 +69,6 @@ var (
azureLogAnalytics: azUSGovLogAnalytics,
azureResourceGraph: azUSGovManagement,
},
azsettings.AzureGermany: {
azureMonitor: azGermanyManagement,
},
azsettings.AzureChina: {
azureMonitor: azChinaManagement,
azureLogAnalytics: azChinaLogAnalytics,