make package_include match output_vagrantfile parsing and abspath calculation

This commit is contained in:
Megan Marsh 2020-05-19 16:32:54 -07:00
parent 1c214628ed
commit a892d13d56
1 changed files with 19 additions and 3 deletions

View File

@ -125,9 +125,12 @@ type Config struct {
AddInsecure bool `mapstructure:"add_insecure" required:"false"` AddInsecure bool `mapstructure:"add_insecure" required:"false"`
// if true, Packer will not call vagrant package to // if true, Packer will not call vagrant package to
// package your base box into its own standalone .box file. // package your base box into its own standalone .box file.
SkipPackage bool `mapstructure:"skip_package" required:"false"` SkipPackage bool `mapstructure:"skip_package" required:"false"`
OutputVagrantfile string `mapstructure:"output_vagrantfile"` OutputVagrantfile string `mapstructure:"output_vagrantfile"`
PackageInclude []string `mapstructure:"package_include"` // Equivalent to setting the
// [`--include`](https://www.vagrantup.com/docs/cli/package.html#include-x-y-z) option
// in `vagrant package`; defaults to unset
PackageInclude []string `mapstructure:"package_include"`
ctx interpolate.Context ctx interpolate.Context
} }
@ -193,6 +196,19 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
} }
} }
if len(b.config.PackageInclude) > 0 {
include := []string{}
for i, inclFile := range b.config.PackageInclude {
b.config.PackageInclude, err = filepath.Abs(b.config.PackageInclude)
if err != nil {
packer.MultiErrorAppend(errs,
fmt.Errorf("unable to determine absolute path for file to be included: %s", inclFile))
}
include = append(include, inclFile)
}
b.config.PackageInclude = include
}
if b.config.TeardownMethod == "" { if b.config.TeardownMethod == "" {
// If we're using a box that's already opened on the system, don't // If we're using a box that's already opened on the system, don't
// automatically destroy it. If we open the box ourselves, then go ahead // automatically destroy it. If we open the box ourselves, then go ahead