From 36df317b892c11e4929ae657706aae61a547c4b8 Mon Sep 17 00:00:00 2001 From: Megan Marsh Date: Wed, 11 Jul 2018 13:30:20 -0700 Subject: [PATCH] don't try to determine file or folder with winrm communicator; not all systems will have powershell installed on them --- communicator/winrm/communicator.go | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/communicator/winrm/communicator.go b/communicator/winrm/communicator.go index 6cf2bce37..bab2ebde2 100644 --- a/communicator/winrm/communicator.go +++ b/communicator/winrm/communicator.go @@ -122,26 +122,11 @@ func runCommand(shell *winrm.Shell, cmd *winrm.Command, rc *packer.RemoteCmd) { } // Upload implementation of communicator.Communicator interface -func (c *Communicator) Upload(path string, input io.Reader, fi *os.FileInfo) error { +func (c *Communicator) Upload(path string, input io.Reader, _ *os.FileInfo) error { wcp, err := c.newCopyClient() - if err != nil { - return err - } - if err != nil { return fmt.Errorf("Was unable to create winrm client: %s", err) } - client, err := c.newWinRMClient() - stdout, _, _, err := client.RunWithString(fmt.Sprintf("powershell -Command \"(Get-Item %s) -is [System.IO.DirectoryInfo]\"", path), "") - if err != nil { - return fmt.Errorf("Couldn't determine whether destination was a folder or file: %s", err) - } - if strings.Contains(stdout, "True") { - // The path exists and is a directory. - // Upload file into the directory instead of overwriting. - path = filepath.Join(path, filepath.Base((*fi).Name())) - } - log.Printf("Uploading file to '%s'", path) return wcp.Write(path, input) }