github.com/sneal/packer@v0.5.2/builder/virtualbox/common/step_suppress_messages.go (about) 1 package common 2 3 import ( 4 "fmt" 5 "github.com/mitchellh/multistep" 6 "github.com/mitchellh/packer/packer" 7 "log" 8 ) 9 10 // This step sets some variables in VirtualBox so that annoying 11 // pop-up messages don't exist. 12 type StepSuppressMessages struct{} 13 14 func (StepSuppressMessages) Run(state multistep.StateBag) multistep.StepAction { 15 driver := state.Get("driver").(Driver) 16 ui := state.Get("ui").(packer.Ui) 17 18 log.Println("Suppressing annoying messages in VirtualBox") 19 if err := driver.SuppressMessages(); err != nil { 20 err := fmt.Errorf("Error configuring VirtualBox to suppress messages: %s", err) 21 state.Put("error", err) 22 ui.Error(err.Error()) 23 return multistep.ActionHalt 24 } 25 26 return multistep.ActionContinue 27 } 28 29 func (StepSuppressMessages) Cleanup(multistep.StateBag) {}