From 7597f609b1cf26cdd5fe78dbe5397c0d9528b12b Mon Sep 17 00:00:00 2001 From: Megan Marsh Date: Fri, 21 Sep 2018 14:19:35 -0700 Subject: [PATCH] update winrmcp vendor and update error message in file provisioner to aid user who messes up file path name. update file provisioner docs --- provisioner/file/provisioner.go | 5 +++++ vendor/github.com/packer-community/winrmcp/winrmcp/cp.go | 6 +++++- vendor/vendor.json | 6 +++--- website/source/docs/provisioners/file.html.md | 6 +++++- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/provisioner/file/provisioner.go b/provisioner/file/provisioner.go index 1be9f1885..6787a20cb 100644 --- a/provisioner/file/provisioner.go +++ b/provisioner/file/provisioner.go @@ -185,6 +185,11 @@ func (p *Provisioner) ProvisionUpload(ui packer.Ui, comm packer.Communicator) er // Upload the file if err = comm.Upload(dst, pf, &fi); err != nil { + if strings.Contains(err.Error(), "Error restoring file") { + ui.Error(fmt.Sprintf("Upload failed: %s; this can occur when "+ + "your file destination is a folder without a trailing "+ + "slash.", err)) + } ui.Error(fmt.Sprintf("Upload failed: %s", err)) return err } diff --git a/vendor/github.com/packer-community/winrmcp/winrmcp/cp.go b/vendor/github.com/packer-community/winrmcp/winrmcp/cp.go index 4d089c13d..2115bcf98 100644 --- a/vendor/github.com/packer-community/winrmcp/winrmcp/cp.go +++ b/vendor/github.com/packer-community/winrmcp/winrmcp/cp.go @@ -117,7 +117,11 @@ func restoreContent(client *winrm.Client, fromPath, toPath string) error { $tmp_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 + if (Test-Path -Path $dest_file_path -PathType container) { + Exit 1 + } else { + rm $dest_file_path + } } else { $dest_dir = ([System.IO.Path]::GetDirectoryName($dest_file_path)) diff --git a/vendor/vendor.json b/vendor/vendor.json index 24a083d4a..c0282a7f3 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -1321,10 +1321,10 @@ "versionExact": "v2.0.0" }, { - "checksumSHA1": "/NoE6t3UkW4/iKAtbf59GGv6tF8=", + "checksumSHA1": "qDOL2Q0BzBA5WwQN06a5/MbEGFQ=", "path": "github.com/packer-community/winrmcp/winrmcp", - "revision": "81144009af586de8e7729b829266f09dd0d59701", - "revisionTime": "2018-01-02T16:08:24Z" + "revision": "0fd363d6159ae26cd0be16262941301e69461641", + "revisionTime": "2018-09-21T17:45:48Z" }, { "checksumSHA1": "oaXvjFg802gS/wx1bx2gAQwa7XQ=", diff --git a/website/source/docs/provisioners/file.html.md b/website/source/docs/provisioners/file.html.md index abb7f10b9..bea2a605e 100644 --- a/website/source/docs/provisioners/file.html.md +++ b/website/source/docs/provisioners/file.html.md @@ -44,7 +44,11 @@ The available configuration options are listed below. - `destination` (string) - The path where the file will be uploaded to in the machine. This value must be a writable location and any parent - directories must already exist. + directories must already exist. If the source is a file, it's a good idea to + make the destination a file as well, but if you set your destination as a + directory, at least make sure that the destination ends in a trailing slash + so that Packer knows to use the source's basename in the final upload path. + Failure to do so may cause Packer to fail on file uploads. - `direction` (string) - The direction of the file transfer. This defaults to "upload". If it is set to "download" then the file "source" in the machine