Chore: Replace core plugins as external warning (#81877)
This commit is contained in:
@@ -193,26 +193,5 @@ func (c *AsExternal) Filter(cl plugins.Class, bundles []*plugins.FoundBundle) ([
|
||||
}
|
||||
return res, nil
|
||||
}
|
||||
|
||||
if cl == plugins.ClassExternal {
|
||||
// Warn if the plugin is not found in the external plugins directory.
|
||||
asExternal := map[string]bool{}
|
||||
for pluginID, pluginCfg := range c.cfg.PluginSettings {
|
||||
if pluginCfg["as_external"] == "true" {
|
||||
asExternal[pluginID] = true
|
||||
}
|
||||
}
|
||||
for _, bundle := range bundles {
|
||||
if asExternal[bundle.Primary.JSONData.ID] {
|
||||
delete(asExternal, bundle.Primary.JSONData.ID)
|
||||
}
|
||||
}
|
||||
if len(asExternal) > 0 {
|
||||
for p := range asExternal {
|
||||
c.log.Error("Core plugin expected to be loaded as external, but it is missing", "pluginID", p)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return bundles, nil
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ import (
|
||||
|
||||
"github.com/grafana/grafana/pkg/plugins"
|
||||
"github.com/grafana/grafana/pkg/plugins/config"
|
||||
"github.com/grafana/grafana/pkg/plugins/log"
|
||||
"github.com/grafana/grafana/pkg/services/featuremgmt"
|
||||
"github.com/grafana/grafana/pkg/setting"
|
||||
)
|
||||
@@ -82,24 +81,4 @@ func TestAsExternal(t *testing.T) {
|
||||
require.Len(t, filtered, 1)
|
||||
require.Equal(t, filtered[0].Primary.JSONData.ID, "plugin2")
|
||||
})
|
||||
|
||||
t.Run("should log an error if an external plugin is not available", func(t *testing.T) {
|
||||
cfg := &config.Cfg{
|
||||
Features: featuremgmt.WithFeatures(featuremgmt.FlagExternalCorePlugins),
|
||||
PluginSettings: setting.PluginSettings{
|
||||
"plugin3": map[string]string{
|
||||
"as_external": "true",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
fakeLogger := log.NewTestLogger()
|
||||
s := NewAsExternalStep(cfg)
|
||||
s.log = fakeLogger
|
||||
|
||||
filtered, err := s.Filter(plugins.ClassExternal, bundles)
|
||||
require.NoError(t, err)
|
||||
require.Len(t, filtered, 2)
|
||||
require.Equal(t, fakeLogger.ErrorLogs.Calls, 1)
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user