Skip to content

Commit

Permalink
Only print out stderr with --local if there's a non-zero exit
Browse files Browse the repository at this point in the history
Optimisation for running k3sup in CI

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <[email protected]>
  • Loading branch information
alexellis committed Oct 7, 2022
1 parent 018b1a0 commit c5b8dc0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
7 changes: 5 additions & 2 deletions cmd/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,9 +266,12 @@ Provide the --local-path flag with --merge if a kubeconfig already exists in som
return err
}

if len(res.StdErr) > 0 {
fmt.Printf("stderr: %q", res.StdErr)
if res.ExitCode != 0 {
if len(res.StdErr) > 0 {
fmt.Printf("stderr: %q", res.StdErr)
}
}

if len(res.StdOut) > 0 {
fmt.Printf("stdout: %q", res.StdOut)
}
Expand Down
5 changes: 3 additions & 2 deletions pkg/operator/exec_operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ func (ex ExecOperator) ExecuteStdio(command string, stream bool) (CommandRes, er
}

return CommandRes{
StdErr: []byte(res.Stderr),
StdOut: []byte(res.Stdout),
StdErr: []byte(res.Stderr),
StdOut: []byte(res.Stdout),
ExitCode: res.ExitCode,
}, nil
}

Expand Down
5 changes: 3 additions & 2 deletions pkg/operator/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ type CommandOperator interface {

// CommandRes contains the STDIO output from running a command
type CommandRes struct {
StdOut []byte
StdErr []byte
StdOut []byte
StdErr []byte
ExitCode int
}

0 comments on commit c5b8dc0

Please sign in to comment.