diff --git a/builder/common/step_provision.go b/builder/common/step_provision.go new file mode 100644 index 000000000..893f13431 --- /dev/null +++ b/builder/common/step_provision.go @@ -0,0 +1,34 @@ +package common + +import ( + "github.com/mitchellh/multistep" + "github.com/mitchellh/packer/packer" + "log" +) + +// StepProvision runs the provisioners. +// +// Uses: +// communicator packer.Communicator +// hook packer.Hook +// ui packer.Ui +// +// Produces: +// +type StepProvision struct{} + +func (*StepProvision) Run(state map[string]interface{}) multistep.StepAction { + comm := state["communicator"].(packer.Communicator) + hook := state["hook"].(packer.Hook) + ui := state["ui"].(packer.Ui) + + log.Println("Running the provision hook") + if err := hook.Run(packer.HookProvision, ui, comm, nil); err != nil { + state["error"] = err + return multistep.ActionHalt + } + + return multistep.ActionContinue +} + +func (*StepProvision) Cleanup(map[string]interface{}) {} diff --git a/builder/common/step_provision_test.go b/builder/common/step_provision_test.go new file mode 100644 index 000000000..6da846cb3 --- /dev/null +++ b/builder/common/step_provision_test.go @@ -0,0 +1,14 @@ +package common + +import ( + "github.com/mitchellh/multistep" + "testing" +) + +func TestStepProvision_Impl(t *testing.T) { + var raw interface{} + raw = new(StepProvision) + if _, ok := raw.(multistep.Step); !ok { + t.Fatalf("provision should be a step") + } +}