Skip to content

Commit

Permalink
file: use excludes list to excl files when uploading a directory
Browse files Browse the repository at this point in the history
Resolves: #9671
  • Loading branch information
Glyphack committed Mar 21, 2023
1 parent 6d6727b commit 33fc558
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion provisioner/file/provisioner.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ type Config struct {
// the Packer run, but realize that there are situations where this may be
// unavoidable.
Generated bool `mapstructure:"generated" required:"false"`
// A list of files or directories to exclude from the upload. This is
// useful if you have a directory with many files and you only want to
// upload a few of them. This only works if you are uploading a directory
// and not a single file.
Excludes []string `mapstructure:"excludes" required:"false"`

ctx interpolate.Context
}
Expand Down Expand Up @@ -227,7 +232,7 @@ func (p *Provisioner) ProvisionUpload(ui packersdk.Ui, comm packersdk.Communicat

// If we're uploading a directory, short circuit and do that
if info.IsDir() {
if err = comm.UploadDir(dst, src, nil); err != nil {
if err = comm.UploadDir(dst, src, p.config.Excludes); err != nil {
ui.Error(fmt.Sprintf("Upload failed: %s", err))
return err
}
Expand Down

0 comments on commit 33fc558

Please sign in to comment.