PluginManager: Increase DI priority (#32111)

* PluginManager: Increase DI priority

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>

* BackendPluginManager: Don't rely on Init

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>

* BackendPluginManager: Fix tests

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>

* Simplify code

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>

* Remove stale field

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>

* Simplify code

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>

Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com>
This commit is contained in:
Arve Knudsen
2021-03-19 12:20:46 +01:00
committed by GitHub
parent 862cd473eb
commit d3544d6df1
5 changed files with 25 additions and 35 deletions

View File

@ -19,25 +19,24 @@ func TestPluginSettings(t *testing.T) {
},
}
ps := extractPluginSettings(cfg)
require.Len(t, ps, 1)
require.Len(t, ps["plugin"], 2)
ps := getPluginSettings("plugin", cfg)
require.Len(t, ps, 2)
t.Run("Should skip path setting", func(t *testing.T) {
cfg.PluginSettings["plugin"]["path"] = "value"
ps := extractPluginSettings(cfg)
require.Len(t, ps["plugin"], 2)
ps := getPluginSettings("plugin", cfg)
require.Len(t, ps, 2)
})
t.Run("Should skip id setting", func(t *testing.T) {
cfg.PluginSettings["plugin"]["id"] = "value"
ps := extractPluginSettings(cfg)
require.Len(t, ps["plugin"], 2)
ps := getPluginSettings("plugin", cfg)
require.Len(t, ps, 2)
})
t.Run("Should return expected environment variables from plugin settings ", func(t *testing.T) {
ps := extractPluginSettings(cfg)
env := ps["plugin"].ToEnv("GF_PLUGIN", []string{"GF_VERSION=6.7.0"})
ps := getPluginSettings("plugin", cfg)
env := ps.ToEnv("GF_PLUGIN", []string{"GF_VERSION=6.7.0"})
sort.Strings(env)
require.Len(t, env, 3)
require.EqualValues(t, []string{"GF_PLUGIN_KEY1=value1", "GF_PLUGIN_KEY2=value2", "GF_VERSION=6.7.0"}, env)