2021-03-13 01:26:07 +08:00
|
|
|
package plugins
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
2021-11-01 17:53:33 +08:00
|
|
|
"github.com/grafana/grafana-plugin-sdk-go/backend"
|
|
|
|
|
|
|
|
"github.com/grafana/grafana/pkg/plugins/backendplugin"
|
2021-03-13 01:26:07 +08:00
|
|
|
)
|
|
|
|
|
2021-11-01 17:53:33 +08:00
|
|
|
// Store is the storage for plugins.
|
|
|
|
type Store interface {
|
|
|
|
// Plugin finds a plugin by its ID.
|
2021-11-17 19:04:22 +08:00
|
|
|
Plugin(ctx context.Context, pluginID string) (PluginDTO, bool)
|
2021-11-01 17:53:33 +08:00
|
|
|
// Plugins returns plugins by their requested type.
|
2021-11-17 19:04:22 +08:00
|
|
|
Plugins(ctx context.Context, pluginTypes ...Type) []PluginDTO
|
2022-06-07 23:51:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
type Manager interface {
|
2021-11-01 17:53:33 +08:00
|
|
|
// Add adds a plugin to the store.
|
2022-08-23 17:50:50 +08:00
|
|
|
Add(ctx context.Context, pluginID, version string, opts CompatOpts) error
|
2021-11-01 17:53:33 +08:00
|
|
|
// Remove removes a plugin from the store.
|
|
|
|
Remove(ctx context.Context, pluginID string) error
|
|
|
|
}
|
|
|
|
|
2022-08-30 23:30:43 +08:00
|
|
|
type PluginSource struct {
|
|
|
|
Class Class
|
|
|
|
Paths []string
|
|
|
|
}
|
|
|
|
|
2022-08-23 17:50:50 +08:00
|
|
|
type CompatOpts struct {
|
|
|
|
GrafanaVersion string
|
|
|
|
OS string
|
|
|
|
Arch string
|
|
|
|
}
|
|
|
|
|
2021-11-01 17:53:33 +08:00
|
|
|
type UpdateInfo struct {
|
|
|
|
PluginZipURL string
|
|
|
|
}
|
|
|
|
|
|
|
|
// Client is used to communicate with backend plugin implementations.
|
|
|
|
type Client interface {
|
|
|
|
backend.QueryDataHandler
|
|
|
|
backend.CheckHealthHandler
|
2021-11-15 21:25:13 +08:00
|
|
|
backend.StreamHandler
|
2021-12-14 18:15:49 +08:00
|
|
|
backend.CallResourceHandler
|
2022-02-10 00:36:53 +08:00
|
|
|
backend.CollectMetricsHandler
|
2021-11-01 17:53:33 +08:00
|
|
|
}
|
|
|
|
|
2022-01-14 20:30:39 +08:00
|
|
|
// BackendFactoryProvider provides a backend factory for a provided plugin.
|
|
|
|
type BackendFactoryProvider interface {
|
|
|
|
BackendFactory(ctx context.Context, p *Plugin) backendplugin.PluginFactoryFunc
|
|
|
|
}
|
|
|
|
|
2021-11-01 17:53:33 +08:00
|
|
|
type RendererManager interface {
|
|
|
|
// Renderer returns a renderer plugin.
|
2022-09-02 20:20:10 +08:00
|
|
|
Renderer(ctx context.Context) *Plugin
|
2021-11-01 17:53:33 +08:00
|
|
|
}
|
|
|
|
|
2022-06-10 01:19:27 +08:00
|
|
|
type SecretsPluginManager interface {
|
|
|
|
// SecretsManager returns a secretsmanager plugin
|
2022-09-02 20:20:10 +08:00
|
|
|
SecretsManager(ctx context.Context) *Plugin
|
2022-06-10 01:19:27 +08:00
|
|
|
}
|
|
|
|
|
2021-11-01 17:53:33 +08:00
|
|
|
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
|
|
|
|
}
|