diff --git a/command/configtype_enumer.go b/command/configtype_enumer.go index 5d02f035855..c7a5cf52a32 100644 --- a/command/configtype_enumer.go +++ b/command/configtype_enumer.go @@ -1,6 +1,5 @@ // Code generated by "enumer -type configType -trimprefix ConfigType -transform snake"; DO NOT EDIT. -// package command import ( diff --git a/packer/fixconfigmode_enumer.go b/packer/fixconfigmode_enumer.go index 82b09a63399..715fa73f558 100644 --- a/packer/fixconfigmode_enumer.go +++ b/packer/fixconfigmode_enumer.go @@ -1,6 +1,5 @@ // Code generated by "enumer -type FixConfigMode"; DO NOT EDIT. -// package packer import ( diff --git a/provisioner/file/provisioner.go b/provisioner/file/provisioner.go index 84e9c3744fa..451a71b0052 100644 --- a/provisioner/file/provisioner.go +++ b/provisioner/file/provisioner.go @@ -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 } @@ -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 } diff --git a/provisioner/file/provisioner.hcl2spec.go b/provisioner/file/provisioner.hcl2spec.go index 3a90f0f3fb1..d6946157430 100644 --- a/provisioner/file/provisioner.hcl2spec.go +++ b/provisioner/file/provisioner.hcl2spec.go @@ -24,6 +24,7 @@ type FlatConfig struct { Destination *string `mapstructure:"destination" required:"true" cty:"destination" hcl:"destination"` Direction *string `mapstructure:"direction" required:"false" cty:"direction" hcl:"direction"` Generated *bool `mapstructure:"generated" required:"false" cty:"generated" hcl:"generated"` + Excludes []string `mapstructure:"excludes" required:"false" cty:"excludes" hcl:"excludes"` } // FlatMapstructure returns a new FlatConfig. @@ -52,6 +53,7 @@ func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec { "destination": &hcldec.AttrSpec{Name: "destination", Type: cty.String, Required: false}, "direction": &hcldec.AttrSpec{Name: "direction", Type: cty.String, Required: false}, "generated": &hcldec.AttrSpec{Name: "generated", Type: cty.Bool, Required: false}, + "excludes": &hcldec.AttrSpec{Name: "excludes", Type: cty.List(cty.String), Required: false}, } return s } diff --git a/provisioner/powershell/executionpolicy_enumer.go b/provisioner/powershell/executionpolicy_enumer.go index b8157b9cfc3..eac957360e8 100644 --- a/provisioner/powershell/executionpolicy_enumer.go +++ b/provisioner/powershell/executionpolicy_enumer.go @@ -1,6 +1,5 @@ // Code generated by "enumer -transform snake -trimprefix ExecutionPolicy -type ExecutionPolicy"; DO NOT EDIT. -// package powershell import ( diff --git a/website/content/partials/provisioner/file/Config-not-required.mdx b/website/content/partials/provisioner/file/Config-not-required.mdx index 1d30c35582e..5e5f6a51307 100644 --- a/website/content/partials/provisioner/file/Config-not-required.mdx +++ b/website/content/partials/provisioner/file/Config-not-required.mdx @@ -18,4 +18,9 @@ the Packer run, but realize that there are situations where this may be unavoidable. +- `excludes` ([]string) - 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. +