2013-12-21 19:04:41 -05:00
|
|
|
package common
|
2013-06-11 18:45:52 -04:00
|
|
|
|
|
|
|
import (
|
2018-01-22 18:32:33 -05:00
|
|
|
"context"
|
2013-06-11 18:45:52 -04:00
|
|
|
"fmt"
|
2018-01-22 18:32:33 -05:00
|
|
|
"log"
|
|
|
|
|
2018-01-19 19:18:44 -05:00
|
|
|
"github.com/hashicorp/packer/helper/multistep"
|
2017-04-04 16:39:01 -04:00
|
|
|
"github.com/hashicorp/packer/packer"
|
2013-06-11 18:45:52 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
// This step sets some variables in VirtualBox so that annoying
|
|
|
|
// pop-up messages don't exist.
|
2013-12-21 19:04:41 -05:00
|
|
|
type StepSuppressMessages struct{}
|
2013-06-11 18:45:52 -04:00
|
|
|
|
2019-03-29 11:50:02 -04:00
|
|
|
func (StepSuppressMessages) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction {
|
2013-12-21 19:04:41 -05:00
|
|
|
driver := state.Get("driver").(Driver)
|
2013-08-31 15:44:58 -04:00
|
|
|
ui := state.Get("ui").(packer.Ui)
|
2013-06-11 18:45:52 -04:00
|
|
|
|
|
|
|
log.Println("Suppressing annoying messages in VirtualBox")
|
|
|
|
if err := driver.SuppressMessages(); err != nil {
|
2013-06-20 00:07:53 -04:00
|
|
|
err := fmt.Errorf("Error configuring VirtualBox to suppress messages: %s", err)
|
2013-08-31 15:44:58 -04:00
|
|
|
state.Put("error", err)
|
2013-06-20 00:07:53 -04:00
|
|
|
ui.Error(err.Error())
|
2013-06-11 18:45:52 -04:00
|
|
|
return multistep.ActionHalt
|
|
|
|
}
|
|
|
|
|
|
|
|
return multistep.ActionContinue
|
|
|
|
}
|
|
|
|
|
2013-12-21 19:04:41 -05:00
|
|
|
func (StepSuppressMessages) Cleanup(multistep.StateBag) {}
|