github.phpd.cn/hashicorp/packer@v1.3.2/builder/lxd/step_provision.go (about) 1 package lxd 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 container 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 ui := state.Get("ui").(packer.Ui) 18 wrappedCommand := state.Get("wrappedCommand").(CommandWrapper) 19 20 // Create our communicator 21 comm := &Communicator{ 22 ContainerName: config.ContainerName, 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) {}