Add option to allow box Vagrantfile to be dynamically generated during build

This commit is contained in:
DanHam 2019-08-05 18:35:01 +01:00
parent 19f3a63ee1
commit 1bffdd9bff
No known key found for this signature in database
GPG Key ID: 58E79AEDD6AA987E
1 changed files with 7 additions and 6 deletions

View File

@ -42,11 +42,12 @@ var builtins = map[string]string{
type Config struct {
common.PackerConfig `mapstructure:",squash"`
CompressionLevel int `mapstructure:"compression_level"`
Include []string `mapstructure:"include"`
OutputPath string `mapstructure:"output"`
Override map[string]interface{}
VagrantfileTemplate string `mapstructure:"vagrantfile_template"`
CompressionLevel int `mapstructure:"compression_level"`
Include []string `mapstructure:"include"`
OutputPath string `mapstructure:"output"`
Override map[string]interface{}
VagrantfileTemplate string `mapstructure:"vagrantfile_template"`
VagrantfileTemplateGenerated bool `mapstructure:"vagrantfile_template_generated"`
ctx interpolate.Context
}
@ -217,7 +218,7 @@ func (p *PostProcessor) configureSingle(c *Config, raws ...interface{}) error {
}
var errs *packer.MultiError
if c.VagrantfileTemplate != "" {
if c.VagrantfileTemplate != "" && c.VagrantfileTemplateGenerated == false {
_, err := os.Stat(c.VagrantfileTemplate)
if err != nil {
errs = packer.MultiErrorAppend(errs, fmt.Errorf(