add debug mode. (#92)

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
Bo-Yi Wu
2017-08-01 16:54:34 +08:00
committed by GitHub
parent 4e625fa760
commit ed83305de8
3 changed files with 18 additions and 1 deletions
+11 -1
View File
@@ -33,6 +33,7 @@ type (
Secrets []string
Envs []string
Proxy easyssh.DefaultConfig
Debug bool
}
// Plugin structure
@@ -89,6 +90,10 @@ func (p Plugin) Exec() error {
},
}
p.log(host, "======CMD======")
p.log(host, strings.Join(p.Config.Script, "\n"))
p.log(host, "======END======")
env := []string{}
for _, key := range p.Config.Envs {
key = strings.ToUpper(key)
@@ -99,7 +104,12 @@ func (p Plugin) Exec() error {
p.Config.Script = append(env, p.Config.Script...)
p.log(host, "commands: ", strings.Join(p.Config.Script, "\n"))
if p.Config.Debug {
p.log(host, "======ENV======")
p.log(host, strings.Join(env, "\n"))
p.log(host, "======END======")
}
stdoutChan, stderrChan, doneChan, errChan, err := ssh.Stream(strings.Join(p.Config.Script, "\n"), p.Config.CommandTimeout)
if err != nil {
errChannel <- err