Plugins: Allow disabling "skip host environment variables" per-plugin (#78266)

* Plugins: Allow disabling skipping host environment variables per-plugin

* Renamed SkipEnvVarsDecorateFunc to SkipHostEnvVarsDecorateFunc

* PR review feedback

* fix tests
This commit is contained in:
Giuseppe Guerra
2023-11-17 16:12:05 +02:00
committed by GitHub
parent ddb7406caa
commit 027a157898
9 changed files with 141 additions and 48 deletions
+14 -6
View File
@@ -20,6 +20,7 @@ import (
"github.com/grafana/grafana/pkg/plugins/manager/pipeline/termination"
"github.com/grafana/grafana/pkg/plugins/manager/pipeline/validation"
"github.com/grafana/grafana/pkg/plugins/manager/sources"
"github.com/grafana/grafana/pkg/services/featuremgmt"
"github.com/grafana/grafana/pkg/services/org"
)
@@ -67,7 +68,7 @@ func TestLoader_Load(t *testing.T) {
{
name: "Load a Core plugin",
class: plugins.ClassCore,
cfg: &config.Cfg{},
cfg: &config.Cfg{Features: featuremgmt.WithFeatures()},
pluginPaths: []string{filepath.Join(corePluginDir, "app/plugins/datasource/cloudwatch")},
want: []*plugins.Plugin{
{
@@ -117,7 +118,7 @@ func TestLoader_Load(t *testing.T) {
{
name: "Load a Bundled plugin",
class: plugins.ClassBundled,
cfg: &config.Cfg{},
cfg: &config.Cfg{Features: featuremgmt.WithFeatures()},
pluginPaths: []string{"../testdata/valid-v2-signature"},
want: []*plugins.Plugin{
{
@@ -157,7 +158,7 @@ func TestLoader_Load(t *testing.T) {
}, {
name: "Load plugin with symbolic links",
class: plugins.ClassExternal,
cfg: &config.Cfg{},
cfg: &config.Cfg{Features: featuremgmt.WithFeatures()},
pluginPaths: []string{"../testdata/symbolic-plugin-dirs"},
want: []*plugins.Plugin{
{
@@ -234,7 +235,8 @@ func TestLoader_Load(t *testing.T) {
name: "Load an unsigned plugin (development)",
class: plugins.ClassExternal,
cfg: &config.Cfg{
DevMode: true,
DevMode: true,
Features: featuremgmt.WithFeatures(),
},
pluginPaths: []string{"../testdata/unsigned-datasource"},
want: []*plugins.Plugin{
@@ -272,7 +274,7 @@ func TestLoader_Load(t *testing.T) {
{
name: "Load an unsigned plugin (production)",
class: plugins.ClassExternal,
cfg: &config.Cfg{},
cfg: &config.Cfg{Features: featuremgmt.WithFeatures()},
pluginPaths: []string{"../testdata/unsigned-datasource"},
want: []*plugins.Plugin{},
},
@@ -281,6 +283,7 @@ func TestLoader_Load(t *testing.T) {
class: plugins.ClassExternal,
cfg: &config.Cfg{
PluginsAllowUnsigned: []string{"test-datasource"},
Features: featuremgmt.WithFeatures(),
},
pluginPaths: []string{"../testdata/unsigned-datasource"},
want: []*plugins.Plugin{
@@ -318,7 +321,7 @@ func TestLoader_Load(t *testing.T) {
{
name: "Load a plugin with v1 manifest should return signatureInvalid",
class: plugins.ClassExternal,
cfg: &config.Cfg{},
cfg: &config.Cfg{Features: featuremgmt.WithFeatures()},
pluginPaths: []string{"../testdata/lacking-files"},
want: []*plugins.Plugin{},
},
@@ -327,6 +330,7 @@ func TestLoader_Load(t *testing.T) {
class: plugins.ClassExternal,
cfg: &config.Cfg{
PluginsAllowUnsigned: []string{"test-datasource"},
Features: featuremgmt.WithFeatures(),
},
pluginPaths: []string{"../testdata/lacking-files"},
want: []*plugins.Plugin{},
@@ -336,6 +340,7 @@ func TestLoader_Load(t *testing.T) {
class: plugins.ClassExternal,
cfg: &config.Cfg{
PluginsAllowUnsigned: []string{"test-datasource"},
Features: featuremgmt.WithFeatures(),
},
pluginPaths: []string{"../testdata/invalid-v2-missing-file"},
want: []*plugins.Plugin{},
@@ -345,6 +350,7 @@ func TestLoader_Load(t *testing.T) {
class: plugins.ClassExternal,
cfg: &config.Cfg{
PluginsAllowUnsigned: []string{"test-datasource"},
Features: featuremgmt.WithFeatures(),
},
pluginPaths: []string{"../testdata/invalid-v2-extra-file"},
want: []*plugins.Plugin{},
@@ -354,6 +360,7 @@ func TestLoader_Load(t *testing.T) {
class: plugins.ClassExternal,
cfg: &config.Cfg{
PluginsAllowUnsigned: []string{"test-app"},
Features: featuremgmt.WithFeatures(),
},
pluginPaths: []string{"../testdata/test-app-with-includes"},
want: []*plugins.Plugin{
@@ -405,6 +412,7 @@ func TestLoader_Load(t *testing.T) {
cfg: &config.Cfg{
DevMode: true,
GrafanaAppSubURL: "grafana",
Features: featuremgmt.WithFeatures(),
},
pluginPaths: []string{"../testdata/unsigned-datasource"},
want: []*plugins.Plugin{