Fixing a small vet warning introduced by PR #1796

While fixing the vet warning also tried to improve any feedback by
showing the actual output/error instead of just the error code.

While testing this I noticed only adding stderr output is not enough as
not all error info is send to stderr, but sometimes also to stdout.
This commit is contained in:
Sander van Harmelen 2015-05-05 21:26:28 +02:00
parent 1045fb9eac
commit 48f4d499f9
1 changed files with 4 additions and 1 deletions

View File

@ -229,8 +229,11 @@ func (c *Communicator) UploadScript(path string, input io.Reader) error {
return err
}
var stdout, stderr bytes.Buffer
cmd := &remote.Cmd{
Command: fmt.Sprintf("chmod 0777 %s", path),
Stdout: &stdout,
Stderr: &stderr,
}
if err := c.Start(cmd); err != nil {
return fmt.Errorf(
@ -241,7 +244,7 @@ func (c *Communicator) UploadScript(path string, input io.Reader) error {
if cmd.ExitStatus != 0 {
return fmt.Errorf(
"Error chmodding script file to 0777 in remote "+
"machine: exit status=%s", cmd.ExitStatus)
"machine: %s %s", stdout.String(), stderr.String())
}
return nil