mirror of
https://github.com/grafana/grafana.git
synced 2025-07-30 20:22:21 +08:00
Plugins: Move discovery logic to plugin sources (#106911)
* move finder behaviour to source * tidy * undo go.mod changes * fix comment * tidy unsafe local source
This commit is contained in:
@ -4,6 +4,8 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
"go.opentelemetry.io/otel/trace"
|
||||
|
||||
"github.com/grafana/grafana/pkg/infra/log"
|
||||
"github.com/grafana/grafana/pkg/infra/tracing"
|
||||
"github.com/grafana/grafana/pkg/plugins"
|
||||
@ -23,7 +25,6 @@ import (
|
||||
"github.com/grafana/grafana/pkg/services/pluginsintegration/pipeline"
|
||||
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginerrs"
|
||||
"github.com/grafana/grafana/pkg/services/rendering"
|
||||
"go.opentelemetry.io/otel/trace"
|
||||
)
|
||||
|
||||
func ProvideService(cfg *config.PluginManagementCfg, pluginEnvProvider envvars.Provider,
|
||||
@ -84,7 +85,7 @@ func (m *Manager) Renderer(ctx context.Context) (rendering.Plugin, bool) {
|
||||
return m.renderer, true
|
||||
}
|
||||
|
||||
srcs, err := sources.DirAsLocalSources(m.cfg.PluginsPath, plugins.ClassExternal)
|
||||
srcs, err := sources.DirAsLocalSources(m.cfg, m.cfg.PluginsPath, plugins.ClassExternal)
|
||||
if err != nil {
|
||||
m.log.Error("Failed to get renderer plugin sources", "error", err)
|
||||
return nil, false
|
||||
@ -109,7 +110,7 @@ func (m *Manager) Renderer(ctx context.Context) (rendering.Plugin, bool) {
|
||||
func createLoader(cfg *config.PluginManagementCfg, pluginEnvProvider envvars.Provider,
|
||||
pr registry.Service, tracer trace.Tracer) (loader.Service, error) {
|
||||
d := discovery.New(cfg, discovery.Opts{
|
||||
FindFilterFuncs: []discovery.FindFilterFunc{
|
||||
FilterFuncs: []discovery.FilterFunc{
|
||||
discovery.NewPermittedPluginTypesFilterStep([]plugins.Type{plugins.TypeRenderer}),
|
||||
func(ctx context.Context, class plugins.Class, bundles []*plugins.FoundBundle) ([]*plugins.FoundBundle, error) {
|
||||
return pipeline.NewDuplicatePluginIDFilterStep(pr).Filter(ctx, bundles)
|
||||
|
Reference in New Issue
Block a user