Some checks failed
continuous-integration/drone/push Build is failing
See #483
31 lines
1.1 KiB
Go
31 lines
1.1 KiB
Go
package ssh
|
|
|
|
import (
|
|
"errors"
|
|
"strings"
|
|
|
|
"github.com/leonelquinteros/gotext"
|
|
)
|
|
|
|
// Fatal is a error output wrapper which aims to make SSH failures easier to
|
|
// parse through re-wording.
|
|
func Fatal(hostname string, err error) error {
|
|
out := err.Error()
|
|
|
|
if strings.Contains(out, "Host key verification failed.") {
|
|
return errors.New(gotext.Get("SSH host key verification failed for %s", hostname))
|
|
} else if strings.Contains(out, "Could not resolve hostname") {
|
|
return errors.New(gotext.Get("could not resolve hostname for %s", hostname))
|
|
} else if strings.Contains(out, "Connection timed out") {
|
|
return errors.New(gotext.Get("connection timed out for %s", hostname))
|
|
} else if strings.Contains(out, "Permission denied") {
|
|
return errors.New(gotext.Get("ssh auth: permission denied for %s", hostname))
|
|
} else if strings.Contains(out, "Network is unreachable") {
|
|
return errors.New(gotext.Get("unable to connect to %s, please check your SSH config", hostname))
|
|
} else if strings.Contains(out, "Is the docker daemon running") {
|
|
return errors.New(gotext.Get("docker: is the daemon running / your user has docker permissions?"))
|
|
}
|
|
|
|
return err
|
|
}
|