Merge pull request #9260 from hashicorp/fix_9256
make package_include match output_vagrantfile parsing and abspath cal…
This commit is contained in:
commit
184dc6cc44
|
@ -140,6 +140,9 @@ type Config struct {
|
|||
// package your base box into its own standalone .box file.
|
||||
SkipPackage bool `mapstructure:"skip_package" required:"false"`
|
||||
OutputVagrantfile string `mapstructure:"output_vagrantfile"`
|
||||
// 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
|
||||
|
@ -192,7 +195,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
|
|||
}
|
||||
if strings.HasSuffix(b.config.SourceBox, ".box") {
|
||||
if _, err := os.Stat(b.config.SourceBox); err != nil {
|
||||
packer.MultiErrorAppend(errs,
|
||||
errs = packer.MultiErrorAppend(errs,
|
||||
fmt.Errorf("Source box '%s' needs to exist at time of config validation! %v", b.config.SourceBox, err))
|
||||
}
|
||||
}
|
||||
|
@ -201,11 +204,22 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
|
|||
if b.config.OutputVagrantfile != "" {
|
||||
b.config.OutputVagrantfile, err = filepath.Abs(b.config.OutputVagrantfile)
|
||||
if err != nil {
|
||||
packer.MultiErrorAppend(errs,
|
||||
errs = packer.MultiErrorAppend(errs,
|
||||
fmt.Errorf("unable to determine absolute path for output vagrantfile: %s", err))
|
||||
}
|
||||
}
|
||||
|
||||
if len(b.config.PackageInclude) > 0 {
|
||||
for i, rawFile := range b.config.PackageInclude {
|
||||
inclFile, err := filepath.Abs(rawFile)
|
||||
if err != nil {
|
||||
errs = packer.MultiErrorAppend(errs,
|
||||
fmt.Errorf("unable to determine absolute path for file to be included: %s", rawFile))
|
||||
}
|
||||
b.config.PackageInclude[i] = inclFile
|
||||
}
|
||||
}
|
||||
|
||||
if b.config.TeardownMethod == "" {
|
||||
// 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
|
||||
|
|
|
@ -83,4 +83,7 @@
|
|||
package your base box into its own standalone .box file.
|
||||
|
||||
- `output_vagrantfile` (string) - Output Vagrantfile
|
||||
- `package_include` ([]string) - Package Include
|
||||
- `package_include` ([]string) - Equivalent to setting the
|
||||
[`--include`](https://www.vagrantup.com/docs/cli/package.html#include-x-y-z) option
|
||||
in `vagrant package`; defaults to unset
|
||||
|
Loading…
Reference in New Issue