mirror of
https://github.com/grafana/grafana.git
synced 2024-11-28 11:44:26 -06:00
2e3e7a7e55
* toying around * fix refs * remove unused fields * go further * add context * ensure streaming handler is set
51 lines
948 B
Go
51 lines
948 B
Go
package api
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/grafana/grafana/pkg/plugins"
|
|
)
|
|
|
|
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
|
|
}
|