mirror of
https://github.com/docker/cli.git
synced 2026-01-23 15:21:32 +03:00
Merge pull request #26869 from anusha-ragunathan/test-fix
Return pipeline errors correctly. Upstream-commit: baa0324e31885e389663806c9a653e54e42fd3fe Component: engine
This commit is contained in:
@@ -68,19 +68,18 @@ func RunCommandPipelineWithOutput(cmds ...*exec.Cmd) (output string, exitCode in
|
||||
}
|
||||
}
|
||||
|
||||
var pipelineError error
|
||||
defer func() {
|
||||
var pipeErrMsgs []string
|
||||
// wait all cmds except the last to release their resources
|
||||
for _, cmd := range cmds[:len(cmds)-1] {
|
||||
if err := cmd.Wait(); err != nil {
|
||||
pipelineError = fmt.Errorf("command %s failed with error: %v", cmd.Path, err)
|
||||
break
|
||||
if pipeErr := cmd.Wait(); pipeErr != nil {
|
||||
pipeErrMsgs = append(pipeErrMsgs, fmt.Sprintf("command %s failed with error: %v", cmd.Path, pipeErr))
|
||||
}
|
||||
}
|
||||
if len(pipeErrMsgs) > 0 && err == nil {
|
||||
err = fmt.Errorf("pipelineError from Wait: %v", strings.Join(pipeErrMsgs, ", "))
|
||||
}
|
||||
}()
|
||||
if pipelineError != nil {
|
||||
return "", 0, pipelineError
|
||||
}
|
||||
|
||||
// wait on last cmd
|
||||
return runCommandWithOutput(cmds[len(cmds)-1])
|
||||
|
||||
Reference in New Issue
Block a user