Skip to content

Commit

Permalink
Merge pull request #5539 from dhaiducek/plugin-errmsg
Browse files Browse the repository at this point in the history
Include exec plugin `stderr` with wrapped error
  • Loading branch information
k8s-ci-robot committed Feb 20, 2024
2 parents 1fa02e7 + 9546529 commit 800e12b
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions api/internal/plugins/execplugin/execplugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,15 +169,16 @@ func (p *ExecPlugin) invokePlugin(input []byte) ([]byte, error) {
p.path, append([]string{f.Name()}, p.args...)...)
cmd.Env = p.getEnv()
cmd.Stdin = bytes.NewReader(input)
cmd.Stderr = os.Stderr
var stdErr bytes.Buffer
cmd.Stderr = &stdErr
if _, err := os.Stat(p.h.Loader().Root()); err == nil {
cmd.Dir = p.h.Loader().Root()
}
result, err := cmd.Output()
if err != nil {
return nil, errors.WrapPrefixf(
err, "failure in plugin configured via %s; %v",
f.Name(), err.Error())
fmt.Errorf("failure in plugin configured via %s; %w",
f.Name(), err), stdErr.String())
}
return result, os.Remove(f.Name())
}
Expand Down

0 comments on commit 800e12b

Please sign in to comment.