From d3268003acce670741a7a4f763bfbde8623ec3c9 Mon Sep 17 00:00:00 2001 From: Austin Roberts Date: Mon, 14 Mar 2022 10:52:22 -0500 Subject: [PATCH] Get plugin details if hook does not match signature --- plugins/plugin_loader.go | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/plugins/plugin_loader.go b/plugins/plugin_loader.go index 5fa6402f1..eb9339a33 100644 --- a/plugins/plugin_loader.go +++ b/plugins/plugin_loader.go @@ -18,8 +18,13 @@ import ( type Subcommand func(*cli.Context, []string) error +type pluginDetails struct { + p *plugin.Plugin + name string +} + type PluginLoader struct { - Plugins []*plugin.Plugin + Plugins []pluginDetails Subcommands map[string]Subcommand Flags []*flag.FlagSet LookupCache map[string][]interface{} @@ -31,9 +36,11 @@ func (pl *PluginLoader) Lookup(name string, validate func(interface{}) bool) []i } results := []interface{}{} for _, plugin := range pl.Plugins { - if v, err := plugin.Lookup(name); err == nil { + if v, err := plugin.p.Lookup(name); err == nil { if validate(v) { results = append(results, v) + } else { + log.Warn("Plugin matches hook but not signature", "plugin", plugin.name, "hook", name) } } } @@ -53,7 +60,7 @@ var DefaultPluginLoader *PluginLoader func NewPluginLoader(target string) (*PluginLoader, error) { pl := &PluginLoader{ - Plugins: []*plugin.Plugin{}, + Plugins: []pluginDetails{}, Subcommands: make(map[string]Subcommand), Flags: []*flag.FlagSet{}, LookupCache: make(map[string][]interface{}), @@ -98,7 +105,7 @@ func NewPluginLoader(target string) (*PluginLoader, error) { } } } - pl.Plugins = append(pl.Plugins, plug) + pl.Plugins = append(pl.Plugins, pluginDetails{plug, fpath}) } return pl, nil }