mirror of
https://github.com/grafana/grafana.git
synced 2024-12-01 21:19:28 -06:00
4a707e2a88
* split out plugin manager * remove whitespace * fix tests * split up tests * updating naming conventions * simplify manager * tidy * add more fakes * testing time * add query verif to int test * renaming * add process tests * tidy up manager tests * add extra case to int test * add more coverage to store and process tests * remove comment * fix capatilization * init on provide * remove addfromsource from API
77 lines
1.7 KiB
Go
77 lines
1.7 KiB
Go
package plugins
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/grafana/grafana-plugin-sdk-go/backend"
|
|
|
|
"github.com/grafana/grafana/pkg/plugins/backendplugin"
|
|
)
|
|
|
|
// Store is the storage for plugins.
|
|
type Store interface {
|
|
// Plugin finds a plugin by its ID.
|
|
Plugin(ctx context.Context, pluginID string) (PluginDTO, bool)
|
|
// Plugins returns plugins by their requested type.
|
|
Plugins(ctx context.Context, pluginTypes ...Type) []PluginDTO
|
|
}
|
|
|
|
type Manager interface {
|
|
// Add adds a plugin to the store.
|
|
Add(ctx context.Context, pluginID, version string, opts CompatOpts) error
|
|
// Remove removes a plugin from the store.
|
|
Remove(ctx context.Context, pluginID string) error
|
|
}
|
|
|
|
type PluginSource struct {
|
|
Class Class
|
|
Paths []string
|
|
}
|
|
|
|
type CompatOpts struct {
|
|
GrafanaVersion string
|
|
OS string
|
|
Arch string
|
|
}
|
|
|
|
type UpdateInfo struct {
|
|
PluginZipURL string
|
|
}
|
|
|
|
// Client is used to communicate with backend plugin implementations.
|
|
type Client interface {
|
|
backend.QueryDataHandler
|
|
backend.CheckHealthHandler
|
|
backend.StreamHandler
|
|
backend.CallResourceHandler
|
|
backend.CollectMetricsHandler
|
|
}
|
|
|
|
// BackendFactoryProvider provides a backend factory for a provided plugin.
|
|
type BackendFactoryProvider interface {
|
|
BackendFactory(ctx context.Context, p *Plugin) backendplugin.PluginFactoryFunc
|
|
}
|
|
|
|
type RendererManager interface {
|
|
// Renderer returns a renderer plugin.
|
|
Renderer() *Plugin
|
|
}
|
|
|
|
type SecretsPluginManager interface {
|
|
// SecretsManager returns a secretsmanager plugin
|
|
SecretsManager() *Plugin
|
|
}
|
|
|
|
type StaticRouteResolver interface {
|
|
Routes() []*StaticRoute
|
|
}
|
|
|
|
type ErrorResolver interface {
|
|
PluginErrors() []*Error
|
|
}
|
|
|
|
type PluginLoaderAuthorizer interface {
|
|
// CanLoadPlugin confirms if a plugin is authorized to load
|
|
CanLoadPlugin(plugin *Plugin) bool
|
|
}
|