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

31 lines
772 B
Go
Raw Normal View History

package common
import (
"fmt"
2018-01-22 20:21:10 -05:00
"log"
2017-04-04 16:39:01 -04:00
"github.com/hashicorp/packer/packer"
"github.com/mitchellh/multistep"
)
// This step suppresses any messages that VMware product might show.
type StepSuppressMessages struct{}
func (s *StepSuppressMessages) Run(state multistep.StateBag) multistep.StepAction {
driver := state.Get("driver").(Driver)
ui := state.Get("ui").(packer.Ui)
vmxPath := state.Get("vmx_path").(string)
log.Println("Suppressing messages in VMX")
if err := driver.SuppressMessages(vmxPath); err != nil {
err := fmt.Errorf("Error suppressing messages: %s", err)
state.Put("error", err)
ui.Error(err.Error())
return multistep.ActionHalt
}
return multistep.ActionContinue
}
func (s *StepSuppressMessages) Cleanup(state multistep.StateBag) {}