mirror of
https://github.com/grafana/grafana.git
synced 2024-12-01 13:09:22 -06:00
788b9afda3
* first pass * use version in more places * add comment * update installer * fix wire * fix tests * tidy * simplify changes * fix in mem * remove unused step * fix step dupe logic for child plugins + add tests
55 lines
1.1 KiB
Go
55 lines
1.1 KiB
Go
package api
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/grafana/grafana/pkg/plugins"
|
|
"github.com/grafana/grafana/pkg/services/rendering"
|
|
)
|
|
|
|
type fakePluginInstaller struct {
|
|
plugins.Installer
|
|
|
|
plugins map[string]fakePlugin
|
|
}
|
|
|
|
type fakePlugin struct {
|
|
pluginID string
|
|
version string
|
|
}
|
|
|
|
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,
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (pm *fakePluginInstaller) Remove(_ context.Context, pluginID, _ string) error {
|
|
delete(pm.plugins, pluginID)
|
|
return nil
|
|
}
|
|
|
|
type fakeRendererPluginManager struct {
|
|
rendering.PluginManager
|
|
}
|
|
|
|
func (ps *fakeRendererPluginManager) Renderer(_ context.Context) (rendering.Plugin, bool) {
|
|
return nil, false
|
|
}
|
|
|
|
type fakePluginStaticRouteResolver struct {
|
|
plugins.StaticRouteResolver
|
|
|
|
routes []*plugins.StaticRoute
|
|
}
|
|
|
|
func (psrr *fakePluginStaticRouteResolver) Routes(_ context.Context) []*plugins.StaticRoute {
|
|
return psrr.routes
|
|
}
|