github.com/phobos182/packer@v0.2.3-0.20130819023704-c84d2aeffc68/common/step_provision.go (about)

     1  package common
     2  
     3  import (
     4  	"github.com/mitchellh/multistep"
     5  	"github.com/mitchellh/packer/packer"
     6  	"log"
     7  )
     8  
     9  // StepProvision runs the provisioners.
    10  //
    11  // Uses:
    12  //   communicator packer.Communicator
    13  //   hook         packer.Hook
    14  //   ui           packer.Ui
    15  //
    16  // Produces:
    17  //   <nothing>
    18  type StepProvision struct{}
    19  
    20  func (*StepProvision) Run(state map[string]interface{}) multistep.StepAction {
    21  	comm := state["communicator"].(packer.Communicator)
    22  	hook := state["hook"].(packer.Hook)
    23  	ui := state["ui"].(packer.Ui)
    24  
    25  	log.Println("Running the provision hook")
    26  	if err := hook.Run(packer.HookProvision, ui, comm, nil); err != nil {
    27  		state["error"] = err
    28  		return multistep.ActionHalt
    29  	}
    30  
    31  	return multistep.ActionContinue
    32  }
    33  
    34  func (*StepProvision) Cleanup(map[string]interface{}) {}