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