Skip to content

Commit

Permalink
fix: Do not create base folder on remote when uploading dir
Browse files Browse the repository at this point in the history
Calling lxc files push dir/ instance:/tmp/abc will create folder
/tmp/abc/dir with all files inside which does not match behavior
expected by Packer - files should be placed directly under /tmp/abc.

Use lxc files push dir/* to upload files to proper directory
  • Loading branch information
Novakov committed Sep 13, 2023
1 parent 397a10e commit a2b80fc
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion builder/lxd/communicator.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"os/exec"
"path/filepath"
"syscall"
"strings"

packersdk "github.com/hashicorp/packer-plugin-sdk/packer"
)
Expand Down Expand Up @@ -92,7 +93,10 @@ func (c *Communicator) Upload(dst string, r io.Reader, fi *os.FileInfo) error {

func (c *Communicator) UploadDir(dst string, src string, exclude []string) error {
fileDestination := fmt.Sprintf("%s/%s", c.ContainerName, dst)
pushCommand := fmt.Sprintf("lxc file push --debug -pr %s %s", src, fileDestination)
if !strings.HasSuffix(src, "/") {
src += "/"
}
pushCommand := fmt.Sprintf("lxc file push --debug -pr %s* %s", src, fileDestination)
log.Printf(pushCommand)
cp, err := c.CmdWrapper(pushCommand)
if err != nil {
Expand Down

0 comments on commit a2b80fc

Please sign in to comment.