Plugins: Create single point of entry for adding / removing plugins (#55463)

* split out plugin manager

* remove whitespace

* fix tests

* split up tests

* updating naming conventions

* simplify manager

* tidy

* explorations

* fix build

* tidy

* fix tests

* add logger helper

* pass the tests

* tidying

* fix tests

* tidy and re-add test

* store depends on loader

* enrich tests

* fix test

* undo gomod changes
This commit is contained in:
Will Browne
2022-09-23 14:27:01 +02:00
committed by GitHub
parent 003a1cdaa0
commit d0d8544ded
21 changed files with 785 additions and 622 deletions
+8 -4
View File
@@ -9,8 +9,8 @@ import (
"github.com/grafana/grafana/pkg/services/pluginsettings"
)
type fakePluginManager struct {
plugins.Manager
type fakePluginInstaller struct {
plugins.Installer
plugins map[string]fakePlugin
}
@@ -20,7 +20,11 @@ type fakePlugin struct {
version string
}
func (pm *fakePluginManager) Add(_ context.Context, pluginID, version string, _ plugins.CompatOpts) error {
func NewFakePluginInstaller() *fakePluginInstaller {
return &fakePluginInstaller{plugins: map[string]fakePlugin{}}
}
func (pm *fakePluginInstaller) Add(_ context.Context, pluginID, version string, _ plugins.CompatOpts) error {
pm.plugins[pluginID] = fakePlugin{
pluginID: pluginID,
version: version,
@@ -28,7 +32,7 @@ func (pm *fakePluginManager) Add(_ context.Context, pluginID, version string, _
return nil
}
func (pm *fakePluginManager) Remove(_ context.Context, pluginID string) error {
func (pm *fakePluginInstaller) Remove(_ context.Context, pluginID string) error {
delete(pm.plugins, pluginID)
return nil
}