packer-cn/builder/virtualbox/common/step_suppress_messages.go

32 lines
850 B
Go
Raw Normal View History

package common
import (
"context"
"fmt"
"log"
2020-12-17 16:29:25 -05:00
"github.com/hashicorp/packer-plugin-sdk/multistep"
packersdk "github.com/hashicorp/packer-plugin-sdk/packer"
)
// This step sets some variables in VirtualBox so that annoying
// pop-up messages don't exist.
type StepSuppressMessages struct{}
func (StepSuppressMessages) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction {
driver := state.Get("driver").(Driver)
ui := state.Get("ui").(packersdk.Ui)
log.Println("Suppressing annoying messages in VirtualBox")
if err := driver.SuppressMessages(); err != nil {
err := fmt.Errorf("Error configuring VirtualBox to suppress messages: %s", err)
2013-08-31 15:44:58 -04:00
state.Put("error", err)
ui.Error(err.Error())
return multistep.ActionHalt
}
return multistep.ActionContinue
}
func (StepSuppressMessages) Cleanup(multistep.StateBag) {}