builder/common: add StepProvision
This commit is contained in:
parent
2cea79c54a
commit
55d3f87f3f
|
@ -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{}) {}
|
|
@ -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")
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue