diff --git a/api/internal/plugins/loader/loader.go b/api/internal/plugins/loader/loader.go index aaa7c36004..1907db96a9 100644 --- a/api/internal/plugins/loader/loader.go +++ b/api/internal/plugins/loader/loader.go @@ -10,6 +10,7 @@ import ( "path/filepath" "plugin" "reflect" + "runtime" "strings" "github.com/pkg/errors" @@ -177,7 +178,8 @@ func (l *Loader) loadPlugin(res *resource.Resource) (resmap.Configurable, error) func (l *Loader) loadExecOrGoPlugin(resId resid.ResId) (resmap.Configurable, error) { // First try to load the plugin as an executable. - p := execplugin.NewExecPlugin(l.absolutePluginPath(resId)) + path, _ := lookForExecutable(l.absolutePluginPath(resId)) + p := execplugin.NewExecPlugin(path) err := p.ErrIfNotExecutable() if err == nil { return p, nil @@ -244,3 +246,21 @@ func copyPlugin(c resmap.Configurable) resmap.Configurable { newNamed := newIndirect.Interface() return newNamed.(resmap.Configurable) } + +func lookForExecutable(partialPath string) (fullPath string, err error) { + if runtime.GOOS != "windows" { + return partialPath, nil + } + + possibleWindowsSuffixes := []string{"exe", "bat", "ps1"} + + for _, possibleWindowsSuffix := range possibleWindowsSuffixes { + fullPath := fmt.Sprintf("%s.%s", partialPath, possibleWindowsSuffix) + _, err := os.Stat(fullPath) + if err == nil { + return fullPath, nil + } + } + + return "", fmt.Errorf("no possible excutable found, partial path: %v tried suffixes: %v", partialPath, possibleWindowsSuffixes) +}