github.com/sneal/packer@v0.5.2/builder/vmware/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 suppresses any messages that VMware product might show.
    11  type StepSuppressMessages struct{}
    12  
    13  func (s *StepSuppressMessages) Run(state multistep.StateBag) multistep.StepAction {
    14  	driver := state.Get("driver").(Driver)
    15  	ui := state.Get("ui").(packer.Ui)
    16  	vmxPath := state.Get("vmx_path").(string)
    17  
    18  	log.Println("Suppressing messages in VMX")
    19  	if err := driver.SuppressMessages(vmxPath); err != nil {
    20  		err := fmt.Errorf("Error suppressing 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 (s *StepSuppressMessages) Cleanup(state multistep.StateBag) {}