Skip to content

Commit

Permalink
Test WinRM client after connection to get better error messages (#19)
Browse files Browse the repository at this point in the history
* Test WinRM client after connection

* Add debug message
  • Loading branch information
kke authored Apr 14, 2021
1 parent 53036bc commit bf6c505
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions winrm.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"time"

"github.com/k0sproject/rig/exec"
"github.com/k0sproject/rig/log"
ps "github.com/k0sproject/rig/powershell"
"github.com/mitchellh/go-homedir"

Expand Down Expand Up @@ -176,6 +177,13 @@ func (c *WinRM) Connect() error {
return err
}

log.Debugf("%s: testing connection", c)
_, err = client.Run("echo ok", ioutil.Discard, ioutil.Discard)
if err != nil {
return err
}
log.Debugf("%s: test passed", c)

c.client = client

return nil
Expand Down

0 comments on commit bf6c505

Please sign in to comment.