Skip to content

Commit

Permalink
Merge pull request #703 from ibuildthecloud/main
Browse files Browse the repository at this point in the history
bug: don't capture stderr for cred and provider tools
  • Loading branch information
ibuildthecloud authored Aug 3, 2024
2 parents 5c3ce90 + 632c2cf commit a2d12ae
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions pkg/engine/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,21 +134,28 @@ func (e *Engine) runCommand(ctx Context, tool types.Tool, input string, toolCate
},
}

result := &bytes.Buffer{}
all := io.MultiWriter(result, &outputWriter{
id: id,
progress: e.Progress,
})

cmd.Stdout = all
cmd.Stderr = all
if log.IsDebug() {
cmd.Stderr = io.MultiWriter(all, os.Stderr)
var (
stdout = &bytes.Buffer{}
stdoutAndErr = &bytes.Buffer{}
progressOut = &outputWriter{
id: id,
progress: e.Progress,
}
result *bytes.Buffer
)

cmd.Stdout = io.MultiWriter(stdout, stdoutAndErr, progressOut)
if toolCategory == NoCategory || toolCategory == ContextToolCategory {
cmd.Stderr = io.MultiWriter(stdoutAndErr, progressOut)
result = stdoutAndErr
} else {
cmd.Stderr = io.MultiWriter(stdoutAndErr, progressOut, os.Stderr)
result = stdout
}

if err := cmd.Run(); err != nil {
if toolCategory == NoCategory {
return fmt.Sprintf("ERROR: got (%v) while running tool, OUTPUT: %s", err, result), nil
return fmt.Sprintf("ERROR: got (%v) while running tool, OUTPUT: %s", err, stdoutAndErr), nil
}
log.Errorf("failed to run tool [%s] cmd %v: %v", tool.Parameters.Name, cmd.Args, err)
return "", fmt.Errorf("ERROR: %s: %w", result, err)
Expand Down

0 comments on commit a2d12ae

Please sign in to comment.