From 89a9e7b5bcd735360bf1622ed3bcf75a676f189c Mon Sep 17 00:00:00 2001 From: Dennis Kaarsemaker Date: Sun, 29 Mar 2026 15:34:30 +0200 Subject: [PATCH] Pass the configuration name to the plugin Now we'll finally see the right name in the progress line. It's a bit of a dodgy hack, as newProvider only accepts one parameter. But it works. --- provider/plugin/provider.go | 12 ++++++++++-- registry.go | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/provider/plugin/provider.go b/provider/plugin/provider.go index 3532713..b398fbb 100644 --- a/provider/plugin/provider.go +++ b/provider/plugin/provider.go @@ -9,6 +9,7 @@ import ( "io" "os" "os/exec" + "strings" "github.com/seveas/herd" "github.com/seveas/herd/provider/plugin/common" @@ -35,11 +36,18 @@ type pluginProvider struct { } func newPlugin(name string) herd.HostProvider { + pname := name + // If the name contains a |, the first part is the binary and the second the configured name + if strings.Contains(name, "|") { + parts := strings.SplitN(name, "|", 2) + pname = parts[0] + name = parts[1] + } p := &pluginProvider{name: name, logger: &logForwarder{}} - if path, err := exec.LookPath(fmt.Sprintf("herd-provider-%s", name)); err == nil { + if path, err := exec.LookPath(fmt.Sprintf("herd-provider-%s", pname)); err == nil { p.config.Command = path } - if path, err := exec.LookPath(fmt.Sprintf("herd-provider-%s.exe", name)); err == nil { + if path, err := exec.LookPath(fmt.Sprintf("herd-provider-%s.exe", pname)); err == nil { p.config.Command = path } return p diff --git a/registry.go b/registry.go index def0c0b..74eb80b 100644 --- a/registry.go +++ b/registry.go @@ -93,7 +93,7 @@ func NewProvider(pname, name string) (HostProvider, error) { // Try finding a plugin by this name, if we have the provider plugin loaded if c, ok := availableProviders["plugin"]; ok { if _, err := exec.LookPath(fmt.Sprintf("herd-provider-%s", pname)); err == nil { - return c(pname), nil + return c(pname + "|" + name), nil } } return nil, fmt.Errorf("No such provider: %s", pname)