mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Plugins: Make Installer responsible for removing plugins from file system (#73323)
* installer is responsible for removing from file system * take plugin as arg * remove resolve step * return plugin in test
This commit is contained in:
@@ -11,5 +11,5 @@ type Service interface {
|
||||
// Load will return a list of plugins found in the provided file system paths.
|
||||
Load(ctx context.Context, src plugins.PluginSource) ([]*plugins.Plugin, error)
|
||||
// Unload will unload a specified plugin from the file system.
|
||||
Unload(ctx context.Context, pluginID string) error
|
||||
Unload(ctx context.Context, p *plugins.Plugin) (*plugins.Plugin, error)
|
||||
}
|
||||
|
||||
@@ -57,6 +57,6 @@ func (l *Loader) Load(ctx context.Context, src plugins.PluginSource) ([]*plugins
|
||||
return initializedPlugins, nil
|
||||
}
|
||||
|
||||
func (l *Loader) Unload(ctx context.Context, pluginID string) error {
|
||||
return l.termination.Terminate(ctx, pluginID)
|
||||
func (l *Loader) Unload(ctx context.Context, p *plugins.Plugin) (*plugins.Plugin, error) {
|
||||
return l.termination.Terminate(ctx, p)
|
||||
}
|
||||
|
||||
@@ -478,7 +478,9 @@ func TestLoader_Load(t *testing.T) {
|
||||
|
||||
func TestLoader_Unload(t *testing.T) {
|
||||
t.Run("Termination stage error is returned from Unload", func(t *testing.T) {
|
||||
pluginID := "grafana-test-panel"
|
||||
plugin := &plugins.Plugin{
|
||||
JSONData: plugins.JSONData{ID: "test-datasource", Type: plugins.TypeDataSource, Info: plugins.Info{Version: "1.0.0"}},
|
||||
}
|
||||
tcs := []struct {
|
||||
expectedErr error
|
||||
}{
|
||||
@@ -496,13 +498,13 @@ func TestLoader_Unload(t *testing.T) {
|
||||
&fakes.FakeValidator{},
|
||||
&fakes.FakeInitializer{},
|
||||
&fakes.FakeTerminator{
|
||||
TerminateFunc: func(ctx context.Context, pID string) error {
|
||||
require.Equal(t, pluginID, pID)
|
||||
return tc.expectedErr
|
||||
TerminateFunc: func(ctx context.Context, p *plugins.Plugin) (*plugins.Plugin, error) {
|
||||
require.Equal(t, plugin, p)
|
||||
return p, tc.expectedErr
|
||||
},
|
||||
})
|
||||
|
||||
err := l.Unload(context.Background(), pluginID)
|
||||
_, err := l.Unload(context.Background(), plugin)
|
||||
require.ErrorIs(t, err, tc.expectedErr)
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user