2013-06-11 18:45:52 -04:00
|
|
|
package virtualbox
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"github.com/mitchellh/multistep"
|
|
|
|
"github.com/mitchellh/packer/packer"
|
|
|
|
"log"
|
|
|
|
)
|
|
|
|
|
|
|
|
// This step sets some variables in VirtualBox so that annoying
|
|
|
|
// pop-up messages don't exist.
|
|
|
|
type stepSuppressMessages struct{}
|
|
|
|
|
2013-08-31 15:44:58 -04:00
|
|
|
func (stepSuppressMessages) Run(state multistep.StateBag) multistep.StepAction {
|
|
|
|
driver := state.Get("driver").(Driver)
|
|
|
|
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-08-31 15:44:58 -04:00
|
|
|
func (stepSuppressMessages) Cleanup(multistep.StateBag) {}
|