CloudWatch: Remove dependencies on grafana/pkg/setting (#81208)
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
pCfg "github.com/grafana/grafana/pkg/plugins/config"
|
||||
"github.com/grafana/grafana/pkg/services/featuremgmt"
|
||||
"github.com/grafana/grafana/pkg/setting"
|
||||
"github.com/grafana/grafana/pkg/util"
|
||||
)
|
||||
|
||||
func ProvideConfig(settingProvider setting.Provider, grafanaCfg *setting.Cfg, features featuremgmt.FeatureToggles) (*pCfg.Cfg, error) {
|
||||
@@ -16,11 +17,19 @@ func ProvideConfig(settingProvider setting.Provider, grafanaCfg *setting.Cfg, fe
|
||||
allowedUnsigned = strings.Split(plugins.KeyValue("allow_loading_unsigned_plugins").Value(), ",")
|
||||
}
|
||||
|
||||
// Get aws settings from settingProvider instead of grafanaCfg
|
||||
aws := settingProvider.Section("aws")
|
||||
allowedAuth := grafanaCfg.AWSAllowedAuthProviders
|
||||
if len(aws.KeyValue("allowed_auth_providers").Value()) > 0 {
|
||||
allowedAuth = util.SplitString(aws.KeyValue("allowed_auth_providers").Value())
|
||||
}
|
||||
if len(allowedAuth) > 0 {
|
||||
allowedUnsigned = strings.Split(settingProvider.KeyValue("plugins", "allow_loading_unsigned_plugins").Value(), ",")
|
||||
}
|
||||
awsForwardSettingsPlugins := grafanaCfg.AWSForwardSettingsPlugins
|
||||
if len(aws.KeyValue("forward_settings_to_plugins").Value()) > 0 {
|
||||
awsForwardSettingsPlugins = util.SplitString(aws.KeyValue("forward_settings_to_plugins").Value())
|
||||
}
|
||||
|
||||
tracingCfg, err := newTracingCfg(grafanaCfg)
|
||||
if err != nil {
|
||||
@@ -35,6 +44,9 @@ func ProvideConfig(settingProvider setting.Provider, grafanaCfg *setting.Cfg, fe
|
||||
allowedAuth,
|
||||
aws.KeyValue("assume_role_enabled").MustBool(grafanaCfg.AWSAssumeRoleEnabled),
|
||||
aws.KeyValue("external_id").Value(),
|
||||
aws.KeyValue("session_duration").Value(),
|
||||
aws.KeyValue("list_metrics_page_limit").Value(),
|
||||
awsForwardSettingsPlugins,
|
||||
grafanaCfg.Azure,
|
||||
grafanaCfg.SecureSocksDSProxy,
|
||||
grafanaCfg.BuildVersion,
|
||||
|
||||
@@ -509,6 +509,7 @@ func TestLoader_Load_ExternalRegistration(t *testing.T) {
|
||||
cfg := &config.Cfg{
|
||||
Features: featuremgmt.WithFeatures(featuremgmt.FlagExternalServiceAuth),
|
||||
PluginsAllowUnsigned: []string{"grafana-test-datasource"},
|
||||
AWSAssumeRoleEnabled: true,
|
||||
}
|
||||
pluginPaths := []string{filepath.Join(testDataDir(t), "oauth-external-registration")}
|
||||
expected := []*plugins.Plugin{
|
||||
@@ -610,6 +611,7 @@ func TestLoader_Load_ExternalRegistration(t *testing.T) {
|
||||
cfg := &config.Cfg{
|
||||
Features: featuremgmt.WithFeatures(featuremgmt.FlagExternalServiceAuth),
|
||||
PluginsAllowUnsigned: []string{"grafana-test-datasource"},
|
||||
AWSAssumeRoleEnabled: true,
|
||||
}
|
||||
pluginPaths := []string{filepath.Join(testDataDir(t), "external-registration")}
|
||||
expected := []*plugins.Plugin{
|
||||
|
||||
@@ -71,7 +71,7 @@ func TestIntegrationPluginManager(t *testing.T) {
|
||||
|
||||
hcp := httpclient.NewProvider()
|
||||
am := azuremonitor.ProvideService(hcp)
|
||||
cw := cloudwatch.ProvideService(cfg, hcp)
|
||||
cw := cloudwatch.ProvideService(hcp)
|
||||
cm := cloudmonitoring.ProvideService(hcp)
|
||||
es := elasticsearch.ProvideService(hcp, tracer)
|
||||
grap := graphite.ProvideService(hcp, tracer)
|
||||
|
||||
Reference in New Issue
Block a user