Merge pull request #8011 from tmeckel/vbox-vm-target-snapshot-optional

Fix: VirtualBox VM builder, target snapshot optional
This commit is contained in:
Megan Marsh 2019-08-19 13:29:06 -07:00 committed by GitHub
commit 8dbd078738
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 4 deletions

View File

@ -163,16 +163,16 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack
// If we were interrupted or cancelled, then just exit.
if _, ok := state.GetOk(multistep.StateCancelled); ok {
return nil, errors.New("Build was cancelled.")
return nil, errors.New("build was cancelled")
}
if _, ok := state.GetOk(multistep.StateHalted); ok {
return nil, errors.New("Build was halted.")
return nil, errors.New("build was halted")
}
if b.config.SkipExport {
return nil, nil
} else {
}
return vboxcommon.NewArtifact(b.config.OutputDir)
}
}

View File

@ -122,11 +122,18 @@ func NewConfig(raws ...interface{}) (*Config, []string, error) {
// Warnings
var warnings []string
if c.TargetSnapshot == "" && c.SkipExport {
warnings = append(warnings,
"No target snapshot is specified (target_snapshot empty) and no export will be created (skip_export=true).\n"+
"You might lose all changes applied by this run, the next time you execute packer.")
}
if c.ShutdownCommand == "" {
warnings = append(warnings,
"A shutdown_command was not specified. Without a shutdown command, Packer\n"+
"will forcibly halt the virtual machine, which may result in data loss.")
}
driver, err := vboxcommon.NewDriver()
if err != nil {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("Failed creating VirtualBox driver: %s", err))