github.phpd.cn/hashicorp/packer@v1.3.2/builder/amazon/chroot/step_chroot_provision.go (about) 1 package chroot 2 3 import ( 4 "context" 5 "log" 6 7 "github.com/hashicorp/packer/helper/multistep" 8 "github.com/hashicorp/packer/packer" 9 ) 10 11 // StepChrootProvision provisions the instance within a chroot. 12 type StepChrootProvision struct { 13 } 14 15 func (s *StepChrootProvision) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { 16 hook := state.Get("hook").(packer.Hook) 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 := &Communicator{ 23 Chroot: mountPath, 24 CmdWrapper: wrappedCommand, 25 } 26 27 // Provision 28 log.Println("Running the provision hook") 29 if err := hook.Run(packer.HookProvision, ui, comm, nil); err != nil { 30 state.Put("error", err) 31 return multistep.ActionHalt 32 } 33 34 return multistep.ActionContinue 35 } 36 37 func (s *StepChrootProvision) Cleanup(state multistep.StateBag) {}