From 7ad77b9e9392ede72e282e582a21290b91585318 Mon Sep 17 00:00:00 2001 From: Eike Verdenhalven Date: Wed, 18 Jan 2017 22:11:48 +0100 Subject: [PATCH] integrate new winrm transport interface --- builder/azure/arm/config.go | 8 +++----- communicator/winrm/config.go | 5 +++-- helper/communicator/config.go | 4 ++-- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/builder/azure/arm/config.go b/builder/azure/arm/config.go index 49ca1cbc2..c1594f510 100644 --- a/builder/azure/arm/config.go +++ b/builder/azure/arm/config.go @@ -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 diff --git a/communicator/winrm/config.go b/communicator/winrm/config.go index f9c989028..728336734 100644 --- a/communicator/winrm/config.go +++ b/communicator/winrm/config.go @@ -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 } diff --git a/helper/communicator/config.go b/helper/communicator/config.go index 57a5a2d7b..5c55fee62 100644 --- a/helper/communicator/config.go +++ b/helper/communicator/config.go @@ -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.