check for a couple errors

This commit is contained in:
Matthew Hooker 2017-03-28 20:35:22 -07:00
parent 35578d9ed1
commit cc11ec3566
No known key found for this signature in database
GPG Key ID: 7B5F933D9CE8C6A1
3 changed files with 13 additions and 4 deletions

View File

@ -69,7 +69,10 @@ func (c *Communicator) Upload(dst string, r io.Reader, fi *os.FileInfo) error {
return fmt.Errorf("Error preparing shell script: %s", err)
}
defer os.Remove(tf.Name())
io.Copy(tf, r)
if _, err := io.Copy(tf, r); err != nil {
return err
}
cpCmd, err := c.CmdWrapper(fmt.Sprintf("cp %s %s", tf.Name(), dst))
if err != nil {

View File

@ -342,7 +342,10 @@ func (s *StepRunSourceInstance) Cleanup(state multistep.StateBag) {
Target: "cancelled",
}
WaitForState(&stateChange)
_, err := WaitForState(&stateChange)
if err != nil {
ui.Error(err.Error())
}
}
@ -359,6 +362,9 @@ func (s *StepRunSourceInstance) Cleanup(state multistep.StateBag) {
Target: "terminated",
}
WaitForState(&stateChange)
_, err := WaitForState(&stateChange)
if err != nil {
ui.Error(err.Error())
}
}
}

View File

@ -250,7 +250,7 @@ func (c *comm) newSession() (session *ssh.Session, err error) {
func (c *comm) reconnect() (err error) {
if c.conn != nil {
c.conn.Close()
return c.conn.Close()
}
// Set the conn and client to nil since we'll recreate it