From e38c1122ab98d8cf4217a97a2a0d537bdfc6a81f Mon Sep 17 00:00:00 2001 From: Chris Bednarski Date: Fri, 6 May 2016 22:57:29 -0700 Subject: [PATCH] Updated vendor pacakge for winrmcp --- Godeps/Godeps.json | 2 +- .../packer-community/winrmcp/winrmcp/cp.go | 20 +++++++++++++++---- .../winrmcp/winrmcp/winrmcp.go | 7 ++++++- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index 700d0256d..e6049ddef 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -1,7 +1,7 @@ { "ImportPath": "github.com/mitchellh/packer", "GoVersion": "go1.6", - "GodepVersion": "v62", + "GodepVersion": "v63", "Deps": [ { "ImportPath": "github.com/ActiveState/tail", diff --git a/vendor/github.com/packer-community/winrmcp/winrmcp/cp.go b/vendor/github.com/packer-community/winrmcp/winrmcp/cp.go index 1065e4529..e36642e25 100644 --- a/vendor/github.com/packer-community/winrmcp/winrmcp/cp.go +++ b/vendor/github.com/packer-community/winrmcp/winrmcp/cp.go @@ -10,18 +10,21 @@ import ( "sync" "github.com/masterzen/winrm/winrm" - "github.com/mitchellh/packer/common/uuid" + "github.com/nu7hatch/gouuid" ) func doCopy(client *winrm.Client, config *Config, in io.Reader, toPath string) error { - tempFile := fmt.Sprintf("winrmcp-%s.tmp", uuid.TimeOrderedUUID()) + tempFile, err := tempFileName() + if err != nil { + return errors.New(fmt.Sprintf("Error generating unique filename: %v", err)) + } tempPath := "$env:TEMP\\" + tempFile if os.Getenv("WINRMCP_DEBUG") != "" { log.Printf("Copying file to %s\n", tempPath) } - err := uploadContent(client, config.MaxOperationsPerShell, "%TEMP%\\"+tempFile, in) + err = uploadContent(client, config.MaxOperationsPerShell, "%TEMP%\\"+tempFile, in) if err != nil { return errors.New(fmt.Sprintf("Error uploading file to %s: %v", tempPath, err)) } @@ -113,7 +116,7 @@ func restoreContent(client *winrm.Client, fromPath, toPath string) error { defer shell.Close() script := fmt.Sprintf(` $tmp_file_path = [System.IO.Path]::GetFullPath("%s") - $dest_file_path = [System.IO.Path]::GetFullPath("%s") + $dest_file_path = [System.IO.Path]::GetFullPath("%s".Trim("'")) if (Test-Path $dest_file_path) { rm $dest_file_path } @@ -198,3 +201,12 @@ func appendContent(shell *winrm.Shell, filePath, content string) error { return nil } + +func tempFileName() (string, error) { + uniquePart, err := uuid.NewV4() + if err != nil { + return "", err + } + + return fmt.Sprintf("winrmcp-%s.tmp", uniquePart), nil +} diff --git a/vendor/github.com/packer-community/winrmcp/winrmcp/winrmcp.go b/vendor/github.com/packer-community/winrmcp/winrmcp/winrmcp.go index d41061b4b..a11ecd180 100644 --- a/vendor/github.com/packer-community/winrmcp/winrmcp/winrmcp.go +++ b/vendor/github.com/packer-community/winrmcp/winrmcp/winrmcp.go @@ -42,7 +42,12 @@ func New(addr string, config *Config) (*Winrmcp, error) { config = &Config{} } - params := winrm.DefaultParameters() + params := winrm.NewParameters( + winrm.DefaultParameters.Timeout, + winrm.DefaultParameters.Locale, + winrm.DefaultParameters.EnvelopeSize, + ) + if config.TransportDecorator != nil { params.TransportDecorator = config.TransportDecorator }