packer-cn/builder/lxd/step_provision.go

35 lines
880 B
Go
Raw Normal View History

2016-05-26 23:21:55 -04:00
package lxd
import (
"github.com/hashicorp/packer/helper/multistep"
2017-09-05 17:09:15 -04:00
"github.com/hashicorp/packer/packer"
"log"
2016-05-26 23:21:55 -04:00
)
// StepProvision provisions the container
2016-05-26 23:21:55 -04:00
type StepProvision struct{}
func (s *StepProvision) Run(_ context.Context, state multistep.StateBag) multistep.StepAction {
2016-05-26 23:21:55 -04:00
hook := state.Get("hook").(packer.Hook)
config := state.Get("config").(*Config)
ui := state.Get("ui").(packer.Ui)
wrappedCommand := state.Get("wrappedCommand").(CommandWrapper)
// Create our communicator
comm := &Communicator{
ContainerName: config.ContainerName,
CmdWrapper: wrappedCommand,
}
// Provision
log.Println("Running the provision hook")
if err := hook.Run(packer.HookProvision, ui, comm, nil); err != nil {
state.Put("error", err)
return multistep.ActionHalt
}
return multistep.ActionContinue
}
func (s *StepProvision) Cleanup(state multistep.StateBag) {}