github.com/mitchellh/packer@v1.3.2/builder/vmware/common/step_suppress_messages.go (about)

     1  package common
     2  
     3  import (
     4  	"context"
     5  	"fmt"
     6  	"log"
     7  
     8  	"github.com/hashicorp/packer/helper/multistep"
     9  	"github.com/hashicorp/packer/packer"
    10  )
    11  
    12  // This step suppresses any messages that VMware product might show.
    13  type StepSuppressMessages struct{}
    14  
    15  func (s *StepSuppressMessages) Run(_ context.Context, state multistep.StateBag) multistep.StepAction {
    16  	driver := state.Get("driver").(Driver)
    17  	ui := state.Get("ui").(packer.Ui)
    18  	vmxPath := state.Get("vmx_path").(string)
    19  
    20  	log.Println("Suppressing messages in VMX")
    21  	if err := driver.SuppressMessages(vmxPath); err != nil {
    22  		err := fmt.Errorf("Error suppressing messages: %s", err)
    23  		state.Put("error", err)
    24  		ui.Error(err.Error())
    25  		return multistep.ActionHalt
    26  	}
    27  
    28  	return multistep.ActionContinue
    29  }
    30  
    31  func (s *StepSuppressMessages) Cleanup(state multistep.StateBag) {}