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:
Will Browne
2025-06-19 10:28:23 +01:00
committed by GitHub
parent 2b21bdf4e1
commit 3d37f969e7
23 changed files with 475 additions and 917 deletions

View File

@ -5,24 +5,16 @@ import (
"slices"
"github.com/grafana/grafana/pkg/plugins"
"github.com/grafana/grafana/pkg/plugins/config"
"github.com/grafana/grafana/pkg/plugins/manager/loader/finder"
)
// DefaultFindFunc is the default function used for the Find step of the Discovery stage. It will scan the local
// filesystem for plugins.
func DefaultFindFunc(cfg *config.PluginManagementCfg) FindFunc {
return finder.NewLocalFinder(cfg.DevMode).Find
}
// PermittedPluginTypesFilter is a filter step that will filter out any plugins that are not of a permitted type.
type PermittedPluginTypesFilter struct {
permittedTypes []plugins.Type
}
// NewPermittedPluginTypesFilterStep returns a new FindFilterFunc for filtering out any plugins that are not of a
// NewPermittedPluginTypesFilterStep returns a new FilterFunc for filtering out any plugins that are not of a
// permitted type. This includes both the primary plugin and any child plugins.
func NewPermittedPluginTypesFilterStep(permittedTypes []plugins.Type) FindFilterFunc {
func NewPermittedPluginTypesFilterStep(permittedTypes []plugins.Type) FilterFunc {
f := &PermittedPluginTypesFilter{
permittedTypes: permittedTypes,
}