@@ -17,7 +17,7 @@ import (
1717func runCommand (cmd string , machID string ) (retcode int ) {
1818 var err error
1919 if machine .IsLocalMachineID (machID ) {
20- err , retcode = runLocalCommand (cmd )
20+ retcode , err = runLocalCommand (cmd )
2121 if err != nil {
2222 fmt .Printf ("Error running local command: %v\n " , err )
2323 }
@@ -27,7 +27,7 @@ func runCommand(cmd string, machID string) (retcode int) {
2727 fmt .Printf ("Error getting machine IP: %v\n " , err )
2828 } else {
2929 sshTimeout := time .Duration (Flags .SSHTimeout * 1000 ) * time .Millisecond
30- err , retcode = runRemoteCommand (cmd , ms .PublicIP , sshTimeout )
30+ retcode , err = runRemoteCommand (cmd , ms .PublicIP , sshTimeout )
3131 if err != nil {
3232 fmt .Printf ("Error running remote command: %v\n " , err )
3333 }
@@ -37,7 +37,7 @@ func runCommand(cmd string, machID string) (retcode int) {
3737}
3838
3939// runLocalCommand runs the given command locally and returns any error encountered and the exit code of the command
40- func runLocalCommand (cmd string ) (error , int ) {
40+ func runLocalCommand (cmd string ) (int , error ) {
4141 cmdSlice := strings .Split (cmd , " " )
4242 osCmd := exec .Command (cmdSlice [0 ], cmdSlice [1 :]... )
4343 osCmd .Stderr = os .Stderr
@@ -48,31 +48,32 @@ func runLocalCommand(cmd string) (error, int) {
4848 // Get the command's exit status if we can
4949 if exiterr , ok := err .(* exec.ExitError ); ok {
5050 if status , ok := exiterr .Sys ().(syscall.WaitStatus ); ok {
51- return nil , status .ExitStatus ()
51+ return status .ExitStatus (), nil
5252 }
5353 }
5454 // Otherwise, generic command error
55- return err , - 1
55+ return - 1 , err
5656 }
57- return nil , 0
57+ return 0 , nil
5858}
5959
6060// runRemoteCommand runs the given command over SSH on the given IP, and returns
6161// any error encountered and the exit status of the command
62- func runRemoteCommand (cmd string , addr string , timeout time.Duration ) (err error , exit int ) {
62+ func runRemoteCommand (cmd string , addr string , timeout time.Duration ) (exit int , err error ) {
6363 var sshClient * ssh.SSHForwardingClient
6464 if tun := getTunnelFlag (); tun != "" {
6565 sshClient , err = ssh .NewTunnelledSSHClient ("core" , tun , addr , getChecker (), false , timeout )
6666 } else {
6767 sshClient , err = ssh .NewSSHClient ("core" , addr , getChecker (), false , timeout )
6868 }
6969 if err != nil {
70- return err , - 1
70+ return - 1 , err
7171 }
7272
7373 defer sshClient .Close ()
7474
75- return ssh .Execute (sshClient , cmd )
75+ err , exit = ssh .Execute (sshClient , cmd )
76+ return
7677}
7778
7879func machineState (machID string ) (* machine.MachineState , error ) {
0 commit comments