From 8d646a1a7338e2e78a05245930952ab5690a8139 Mon Sep 17 00:00:00 2001 From: Filipe Pina Date: Tue, 9 Nov 2021 10:49:09 +0000 Subject: [PATCH] look for plugins in the config path used (as documented) instead of hardcoded /etc/dkron --- cmd/plugins.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/cmd/plugins.go b/cmd/plugins.go index 772d99bb4..c6e75999a 100644 --- a/cmd/plugins.go +++ b/cmd/plugins.go @@ -12,6 +12,7 @@ import ( "github.com/hashicorp/go-plugin" "github.com/kardianos/osext" "github.com/sirupsen/logrus" + "github.com/spf13/viper" ) type Plugins struct { @@ -33,14 +34,19 @@ func (p *Plugins) DiscoverPlugins() error { p.Processors = make(map[string]dkplugin.Processor) p.Executors = make(map[string]dkplugin.Executor) - // Look in /etc/dkron/plugins - processors, err := plugin.Discover("dkron-processor-*", filepath.Join("/etc", "dkron", "plugins")) + pluginDir := filepath.Join("/etc", "dkron", "plugins") + if viper.ConfigFileUsed() != "" { + pluginDir = filepath.Join(filepath.Dir(viper.ConfigFileUsed()), "plugins") + } + + // Look in /etc/dkron/plugins (or the used config path) + processors, err := plugin.Discover("dkron-processor-*", pluginDir) if err != nil { return err } - // Look in /etc/dkron/plugins - executors, err := plugin.Discover("dkron-executor-*", filepath.Join("/etc", "dkron", "plugins")) + // Look in /etc/dkron/plugins (or the used config path) + executors, err := plugin.Discover("dkron-executor-*", pluginDir) if err != nil { return err }