[Salt] Replace scp with scp + mv to handle non-root case

This commit is contained in:
David Hao 2019-07-02 18:06:04 -04:00
parent 32066cc46e
commit c6a471d149
1 changed files with 9 additions and 9 deletions

View File

@ -399,9 +399,14 @@ func (p *Provisioner) uploadFile(ui packer.Ui, comm packer.Communicator, dst, sr
} }
defer f.Close() defer f.Close()
if err = comm.Upload(dst, f, nil); err != nil { _, temp_dst := filepath.Split(dst)
if err = comm.Upload(temp_dst, f, nil); err != nil {
return fmt.Errorf("Error uploading %s: %s", src, err) return fmt.Errorf("Error uploading %s: %s", src, err)
} }
p.moveFile(ui, comm, dst, temp_dst)
return nil return nil
} }
@ -468,14 +473,9 @@ func (p *Provisioner) removeDir(ui packer.Ui, comm packer.Communicator, dir stri
} }
func (p *Provisioner) uploadDir(ui packer.Ui, comm packer.Communicator, dst, src string, ignore []string) error { func (p *Provisioner) uploadDir(ui packer.Ui, comm packer.Communicator, dst, src string, ignore []string) error {
if err := p.createDir(ui, comm, dst); err != nil { _, temp_dst := filepath.Split(dst)
if err := comm.UploadDir(temp_dst, src, ignore); err != nil {
return err return err
} }
return p.moveFile(ui, comm, dst, temp_dst)
// Make sure there is a trailing "/" so that the directory isn't
// created on the other side.
if src[len(src)-1] != '/' {
src = src + "/"
}
return comm.UploadDir(dst, src, ignore)
} }