Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions provider/plugin/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"io"
"os"
"os/exec"
"strings"

"github.com/seveas/herd"
"github.com/seveas/herd/provider/plugin/common"
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down