mirror of
https://github.com/grafana/grafana.git
synced 2025-02-15 10:03:33 -06:00
* installer -> repo * add semver format checking * add plugin callbacks in test * remove newline * post install only scans new directories * remove unused stuff * everything in own package * add missing cli params * make grafana version part of the API * resolve conflicts * tidy up logger * fix cli and tidy log statements * rename log package * update struct name * fix linter issue * fs -> filestore * reorder imports * alias import * fix test * fix test * inline var * revert jsonc file * make repo dep of manager * actually inject the thing * accept all args for compatability checks * accept compat from store * pass os + arch vals * don't inject fs * tidy up * tidy up * merge with main and tidy fs storage * fix test * fix packages * fix comment + field name * update fs naming * fixed wire * remove unused func * fix mocks * fix storage test * renaming * fix log line * fix test * re-order field * tidying * add test for update with same version * fix wire for CLI * remove use of ioutil * don't pass field * small tidy * ignore code scanning warn * fix testdata link * update lgtm code
73 lines
1.4 KiB
Go
73 lines
1.4 KiB
Go
package api
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/grafana/grafana/pkg/plugins"
|
|
)
|
|
|
|
type fakePluginManager struct {
|
|
plugins map[string]fakePlugin
|
|
}
|
|
|
|
type fakePlugin struct {
|
|
pluginID string
|
|
version string
|
|
}
|
|
|
|
func (pm *fakePluginManager) Add(_ context.Context, pluginID, version string, _ plugins.CompatOpts) error {
|
|
pm.plugins[pluginID] = fakePlugin{
|
|
pluginID: pluginID,
|
|
version: version,
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (pm *fakePluginManager) Remove(_ context.Context, pluginID string) error {
|
|
delete(pm.plugins, pluginID)
|
|
return nil
|
|
}
|
|
|
|
type fakePluginStore struct {
|
|
plugins.Store
|
|
|
|
plugins map[string]plugins.PluginDTO
|
|
}
|
|
|
|
func (pr fakePluginStore) Plugin(_ context.Context, pluginID string) (plugins.PluginDTO, bool) {
|
|
p, exists := pr.plugins[pluginID]
|
|
|
|
return p, exists
|
|
}
|
|
|
|
func (pr fakePluginStore) Plugins(_ context.Context, pluginTypes ...plugins.Type) []plugins.PluginDTO {
|
|
var result []plugins.PluginDTO
|
|
for _, v := range pr.plugins {
|
|
for _, t := range pluginTypes {
|
|
if v.Type == t {
|
|
result = append(result, v)
|
|
}
|
|
}
|
|
}
|
|
|
|
return result
|
|
}
|
|
|
|
type fakeRendererManager struct {
|
|
plugins.RendererManager
|
|
}
|
|
|
|
func (ps *fakeRendererManager) Renderer() *plugins.Plugin {
|
|
return nil
|
|
}
|
|
|
|
type fakePluginStaticRouteResolver struct {
|
|
plugins.StaticRouteResolver
|
|
|
|
routes []*plugins.StaticRoute
|
|
}
|
|
|
|
func (psrr *fakePluginStaticRouteResolver) Routes() []*plugins.StaticRoute {
|
|
return psrr.routes
|
|
}
|