github.com/mmcquillan/packer@v1.1.1-0.20171009221028-c85cf0483a5d/builder/lxc/step_provision.go (about) 1 package lxc 2 3 import ( 4 "github.com/hashicorp/packer/packer" 5 "github.com/mitchellh/multistep" 6 "log" 7 ) 8 9 // StepProvision provisions the instance within a chroot. 10 type StepProvision struct{} 11 12 func (s *StepProvision) Run(state multistep.StateBag) multistep.StepAction { 13 hook := state.Get("hook").(packer.Hook) 14 config := state.Get("config").(*Config) 15 mountPath := state.Get("mount_path").(string) 16 ui := state.Get("ui").(packer.Ui) 17 wrappedCommand := state.Get("wrappedCommand").(CommandWrapper) 18 19 // Create our communicator 20 comm := &LxcAttachCommunicator{ 21 ContainerName: config.ContainerName, 22 RootFs: mountPath, 23 CmdWrapper: wrappedCommand, 24 } 25 26 // Provision 27 log.Println("Running the provision hook") 28 if err := hook.Run(packer.HookProvision, ui, comm, nil); err != nil { 29 state.Put("error", err) 30 return multistep.ActionHalt 31 } 32 33 return multistep.ActionContinue 34 } 35 36 func (s *StepProvision) Cleanup(state multistep.StateBag) {}