diff --git a/client/commonplugins/secrets_plugin.go b/client/commonplugins/secrets_plugin.go index 110f23d6f..2679a34cb 100644 --- a/client/commonplugins/secrets_plugin.go +++ b/client/commonplugins/secrets_plugin.go @@ -10,6 +10,7 @@ import ( "os" "os/exec" "path/filepath" + "runtime" "time" log "github.com/hashicorp/go-hclog" @@ -51,6 +52,9 @@ type externalSecretsPlugin struct { // which will be used as environment variables for Fetch. func NewExternalSecretsPlugin(commonPluginDir string, name string, env map[string]string) (*externalSecretsPlugin, error) { // validate plugin + if runtime.GOOS == "windows" { + name += ".exe" + } executable := filepath.Join(commonPluginDir, SecretsPluginDir, name) f, err := os.Stat(executable) if err != nil { diff --git a/client/fingerprint/secrets.go b/client/fingerprint/secrets.go index fe489338b..a8a79508c 100644 --- a/client/fingerprint/secrets.go +++ b/client/fingerprint/secrets.go @@ -53,6 +53,7 @@ func (s *SecretsPluginFingerprint) Fingerprint(request *FingerprintRequest, resp // map of plugin names to fingerprinted versions plugins := map[string]string{} for name := range files { + name = strings.TrimSuffix(name, ".exe") plug, err := commonplugins.NewExternalSecretsPlugin(request.Config.CommonPluginDir, name, nil) if err != nil { return err diff --git a/helper/funcs.go b/helper/funcs.go index 2695540ff..e1af5f2a8 100644 --- a/helper/funcs.go +++ b/helper/funcs.go @@ -569,7 +569,3 @@ func FindExecutableFiles(path string) (map[string]string, error) { } return executables, nil } - -func IsExecutable(i os.FileInfo) bool { - return !i.IsDir() && i.Mode()&0o111 != 0 -} diff --git a/helper/funcs_unix.go b/helper/funcs_unix.go new file mode 100644 index 000000000..398dd6f9e --- /dev/null +++ b/helper/funcs_unix.go @@ -0,0 +1,13 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: BUSL-1.1 + +//go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris +// +build darwin dragonfly freebsd linux netbsd openbsd solaris + +package helper + +import "os" + +func IsExecutable(i os.FileInfo) bool { + return !i.IsDir() && i.Mode()&0o111 != 0 +} diff --git a/helper/funcs_windows.go b/helper/funcs_windows.go new file mode 100644 index 000000000..fdf46e2cb --- /dev/null +++ b/helper/funcs_windows.go @@ -0,0 +1,16 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: BUSL-1.1 + +//go:build windows +// +build windows + +package helper + +import ( + "os" + "strings" +) + +func IsExecutable(i os.FileInfo) bool { + return strings.HasSuffix(i.Name(), ".exe") +}