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