Skip to content

Commit

Permalink
sdk: Add ExitStatus to CommandResult
Browse files Browse the repository at this point in the history
  • Loading branch information
mumoshu committed Jan 25, 2021
1 parent c6cb656 commit 1b0a95e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions pkg/sdk/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ func Run(cmd *exec.Cmd) (*CommandResult, error) {
//case <-ctx.Done():
}

res := NewCommandResult()

out := output.String()
log.Printf("[DEBUG] command %q finished with output: \"%s\"", cmdToLog, out)
var exitStatus int
Expand All @@ -72,12 +74,12 @@ func Run(cmd *exec.Cmd) (*CommandResult, error) {
if exitStatus != 2 {
return nil, fmt.Errorf("%s: %v\n%s", cmd.Path, runErr, out)
}
res.ExitStatus = exitStatus
default:
return nil, fmt.Errorf("running %q: %v\n%s", cmdToLog, runErr, out)
}
}

res := NewCommandResult()
res.Output = out

log.Printf("[DEBUG] command new state: \"%v\"", res)
Expand Down Expand Up @@ -134,7 +136,8 @@ func logDebug(title string, data interface{}) {

// CommandResult is a wrapper around both the input and output attributes that are relavent for updates
type CommandResult struct {
Output string
Output string
ExitStatus int
}

// NewCommandResult is the constructor for CommandResult
Expand Down

0 comments on commit 1b0a95e

Please sign in to comment.