mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
print scp error before exiting on error code
See if there is any additional stderr output before exiting, since it can be helpful in addition to the error status.
This commit is contained in:
parent
0c94e20a83
commit
6cac02df14
@ -481,6 +481,13 @@ func (c *Communicator) scpSession(scpCommand string, f func(io.Writer, *bufio.Re
|
||||
// our data and has completed. Or has errored.
|
||||
log.Println("[DEBUG] Waiting for SSH session to complete.")
|
||||
err = session.Wait()
|
||||
|
||||
// log any stderr before exiting on an error
|
||||
scpErr := stderr.String()
|
||||
if len(scpErr) > 0 {
|
||||
log.Printf("[ERROR] scp stderr: %q", stderr)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
if exitErr, ok := err.(*ssh.ExitError); ok {
|
||||
// Otherwise, we have an ExitErorr, meaning we can just read
|
||||
@ -499,11 +506,6 @@ func (c *Communicator) scpSession(scpCommand string, f func(io.Writer, *bufio.Re
|
||||
return err
|
||||
}
|
||||
|
||||
scpErr := stderr.String()
|
||||
if len(scpErr) > 0 {
|
||||
log.Printf("[ERROR] scp stderr: %q", stderr)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user