builder/common: add StepProvision

This commit is contained in:
Mitchell Hashimoto 2013-07-16 15:43:01 +09:00
parent 2cea79c54a
commit 55d3f87f3f
2 changed files with 48 additions and 0 deletions

View File

@ -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:
// <nothing>
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{}) {}

View File

@ -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")
}
}