secrets: Support custom plugins in Windows (#26751)

Signed-off-by: Olli Janatuinen <olli.janatuinen@gmail.com>
This commit is contained in:
Olli Janatuinen
2025-09-16 15:14:50 +02:00
committed by GitHub
parent f47cb5d10f
commit 6398ef9475
5 changed files with 34 additions and 4 deletions

View File

@@ -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 {

View File

@@ -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