integrate new winrm transport interface

This commit is contained in:
Eike Verdenhalven 2017-01-18 22:11:48 +01:00
parent 525d7c946e
commit 7ad77b9e93
3 changed files with 8 additions and 9 deletions

View File

@ -13,7 +13,6 @@ import (
"fmt"
"io/ioutil"
"math/big"
"net/http"
"regexp"
"strings"
"time"
@ -21,7 +20,7 @@ import (
"github.com/Azure/azure-sdk-for-go/arm/compute"
"github.com/Azure/go-autorest/autorest/azure"
"github.com/Azure/go-autorest/autorest/to"
"github.com/Azure/go-ntlmssp"
"github.com/masterzen/winrm"
"github.com/mitchellh/packer/builder/azure/common/constants"
"github.com/mitchellh/packer/builder/azure/pkcs12"
@ -275,9 +274,8 @@ func setSshValues(c *Config) error {
}
func setWinRMCertificate(c *Config) error {
c.Comm.WinRMTransportDecorator = func(t *http.Transport) http.RoundTripper {
return &ntlmssp.Negotiator{RoundTripper: t}
}
c.Comm.WinRMTransportDecorator =
func() winrm.Transporter { return &winrm.ClientNTLM{} }
cert, err := c.createCertificate()
c.winrmCertificate = cert

View File

@ -1,8 +1,9 @@
package winrm
import (
"net/http"
"time"
"github.com/masterzen/winrm"
)
// Config is used to configure the WinRM connection
@ -14,5 +15,5 @@ type Config struct {
Timeout time.Duration
Https bool
Insecure bool
TransportDecorator func(*http.Transport) http.RoundTripper
TransportDecorator func() winrm.Transporter
}

View File

@ -3,10 +3,10 @@ package communicator
import (
"errors"
"fmt"
"net/http"
"os"
"time"
"github.com/masterzen/winrm"
"github.com/mitchellh/packer/template/interpolate"
)
@ -41,7 +41,7 @@ type Config struct {
WinRMTimeout time.Duration `mapstructure:"winrm_timeout"`
WinRMUseSSL bool `mapstructure:"winrm_use_ssl"`
WinRMInsecure bool `mapstructure:"winrm_insecure"`
WinRMTransportDecorator func(*http.Transport) http.RoundTripper
WinRMTransportDecorator func() winrm.Transporter
}
// Port returns the port that will be used for access based on config.