Skip to content

Commit

Permalink
Include command in error from kubectl commands
Browse files Browse the repository at this point in the history
Signed-off-by: Dale Haiducek <[email protected]>
(cherry picked from commit 8b82c50)
  • Loading branch information
dhaiducek authored and Magic Mirror committed Feb 19, 2024
1 parent 5889cb0 commit 7c8f997
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions test/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -302,10 +302,16 @@ func KubectlWithOutput(args ...string) (string, error) {

output, err := kubectlCmd.CombinedOutput()
if err != nil {
return string(output), fmt.Errorf("error running kubectl command: %s: %s", output, err.Error())
// Reformat error to include kubectl command and stderr output
err = fmt.Errorf(
"error running command '%s':\n %s: %s",
strings.Join(kubectlCmd.Args, " "),
output,
err.Error(),
)
}

return string(output), nil
return string(output), err
}

// GetMetrics execs into the propagator pod and curls the metrics endpoint, filters
Expand Down

0 comments on commit 7c8f997

Please sign in to comment.