udpate winrmcp

This commit is contained in:
James Bardin 2018-04-05 11:01:01 -04:00
parent abfb43555a
commit dc8c1534fe
2 changed files with 33 additions and 7 deletions

View File

@ -176,13 +176,35 @@ func cleanupContent(client *winrm.Client, filePath string) error {
} }
defer shell.Close() defer shell.Close()
cmd, err := shell.Execute("powershell", "Remove-Item", filePath, "-ErrorAction SilentlyContinue") script := fmt.Sprintf(`
$tmp_file_path = [System.IO.Path]::GetFullPath("%s")
if (Test-Path $tmp_file_path) {
Remove-Item $tmp_file_path -ErrorAction SilentlyContinue
}
`, filePath)
cmd, err := shell.Execute(winrm.Powershell(script))
if err != nil { if err != nil {
return err return err
} }
defer cmd.Close()
var wg sync.WaitGroup
copyFunc := func(w io.Writer, r io.Reader) {
defer wg.Done()
io.Copy(w, r)
}
wg.Add(2)
go copyFunc(os.Stdout, cmd.Stdout)
go copyFunc(os.Stderr, cmd.Stderr)
cmd.Wait() cmd.Wait()
cmd.Close() wg.Wait()
if cmd.ExitCode() != 0 {
return fmt.Errorf("cleanup operation returned code=%d", cmd.ExitCode())
}
return nil return nil
} }

14
vendor/vendor.json vendored
View File

@ -2107,14 +2107,18 @@
{ {
"checksumSHA1": "dIMJD0AZwSwmuOuTaGgqWZkzuPU=", "checksumSHA1": "dIMJD0AZwSwmuOuTaGgqWZkzuPU=",
"path": "github.com/packer-community/winrmcp", "path": "github.com/packer-community/winrmcp",
"revision": "078cc0a785c9da54158c0775f06f505fc1e867f8", "revision": "81144009af586de8e7729b829266f09dd0d59701",
"revisionTime": "2017-06-07T14:21:56Z" "revisionTime": "2018-01-02T16:08:24Z",
"version": "master",
"versionExact": "master"
}, },
{ {
"checksumSHA1": "iApv8tX8vuAvzyY6VkOvW+IzJF8=", "checksumSHA1": "/NoE6t3UkW4/iKAtbf59GGv6tF8=",
"path": "github.com/packer-community/winrmcp/winrmcp", "path": "github.com/packer-community/winrmcp/winrmcp",
"revision": "078cc0a785c9da54158c0775f06f505fc1e867f8", "revision": "81144009af586de8e7729b829266f09dd0d59701",
"revisionTime": "2017-06-07T14:21:56Z" "revisionTime": "2018-01-02T16:08:24Z",
"version": "master",
"versionExact": "master"
}, },
{ {
"checksumSHA1": "rJab1YdNhQooDiBWNnt7TLWPyBU=", "checksumSHA1": "rJab1YdNhQooDiBWNnt7TLWPyBU=",