Chore: Bump grafana-azure-sdk-go to v1.12.0 and expose AzureAuthEnabled value in config (#81807)

* upgrade grafana-azure-sdk-go v1.12.0

* add AzureAuthEnabled to config
This commit is contained in:
ismail simsek
2024-02-05 13:36:33 +01:00
committed by GitHub
parent 80e58f98a7
commit 2002a6c4fb
6 changed files with 56 additions and 9 deletions
+4 -2
View File
@@ -26,7 +26,8 @@ type Cfg struct {
AWSExternalId string
// Azure Cloud settings
Azure *azsettings.AzureSettings
Azure *azsettings.AzureSettings
AzureAuthEnabled bool
// Proxy Settings
ProxySettings setting.SecureSocksDSProxySettings
@@ -55,7 +56,7 @@ type Cfg struct {
func NewCfg(devMode bool, pluginsPath string, pluginSettings setting.PluginSettings, pluginsAllowUnsigned []string,
awsAllowedAuthProviders []string, awsAssumeRoleEnabled bool, awsExternalId string, azure *azsettings.AzureSettings, secureSocksDSProxy setting.SecureSocksDSProxySettings,
grafanaVersion string, logDatasourceRequests bool, pluginsCDNURLTemplate string, appURL string, appSubURL string, tracing Tracing, features featuremgmt.FeatureToggles, angularSupportEnabled bool,
grafanaComURL string, disablePlugins []string, hideAngularDeprecation []string, forwardHostEnvVars []string, concurrentQueryCount int) *Cfg {
grafanaComURL string, disablePlugins []string, hideAngularDeprecation []string, forwardHostEnvVars []string, concurrentQueryCount int, azureAuthEnabled bool) *Cfg {
return &Cfg{
log: log.New("plugin.cfg"),
PluginsPath: pluginsPath,
@@ -80,5 +81,6 @@ func NewCfg(devMode bool, pluginsPath string, pluginSettings setting.PluginSetti
HideAngularDeprecation: hideAngularDeprecation,
ForwardHostEnvVars: forwardHostEnvVars,
ConcurrentQueryCount: concurrentQueryCount,
AzureAuthEnabled: azureAuthEnabled,
}
}
+3
View File
@@ -151,6 +151,9 @@ func (s *Service) GetConfigMap(ctx context.Context, pluginID string, _ *auth.Ext
}
// Settings here will be extracted by grafana-azure-sdk-go from the plugin context
if s.cfg.AzureAuthEnabled {
m[azsettings.AzureAuthEnabled] = strconv.FormatBool(s.cfg.AzureAuthEnabled)
}
azureSettings := s.cfg.Azure
if azureSettings != nil && slices.Contains[[]string, string](azureSettings.ForwardSettingsPlugins, pluginID) {
if azureSettings.Cloud != "" {
+27
View File
@@ -825,6 +825,33 @@ func TestService_GetConfigMap_concurrentQueryCount(t *testing.T) {
})
}
func TestService_GetConfigMap_azureAuthEnabled(t *testing.T) {
t.Run("Uses the configured azureAuthEnabled", func(t *testing.T) {
s := &Service{
cfg: &config.Cfg{
AzureAuthEnabled: true,
},
}
require.Equal(t, map[string]string{"GFAZPL_AZURE_AUTH_ENABLED": "true"}, s.GetConfigMap(context.Background(), "", nil))
})
t.Run("Doesn't set the azureAuthEnabled if it is not in the config", func(t *testing.T) {
s := &Service{
cfg: &config.Cfg{},
}
require.Equal(t, map[string]string{}, s.GetConfigMap(context.Background(), "", nil))
})
t.Run("Doesn't set the azureAuthEnabled if it is false", func(t *testing.T) {
s := &Service{
cfg: &config.Cfg{
AzureAuthEnabled: false,
},
}
require.Equal(t, map[string]string{}, s.GetConfigMap(context.Background(), "", nil))
})
}
func TestService_GetConfigMap_azure(t *testing.T) {
azSettings := &azsettings.AzureSettings{
Cloud: azsettings.AzurePublic,