github.com/rothwerx/packer@v0.9.0/builder/amazon/chroot/step_chroot_provision.go (about) 1 package chroot 2 3 import ( 4 "github.com/mitchellh/multistep" 5 "github.com/mitchellh/packer/packer" 6 "log" 7 ) 8 9 // StepChrootProvision provisions the instance within a chroot. 10 type StepChrootProvision struct { 11 mounts []string 12 } 13 14 func (s *StepChrootProvision) Run(state multistep.StateBag) multistep.StepAction { 15 hook := state.Get("hook").(packer.Hook) 16 mountPath := state.Get("mount_path").(string) 17 ui := state.Get("ui").(packer.Ui) 18 wrappedCommand := state.Get("wrappedCommand").(CommandWrapper) 19 20 // Create our communicator 21 comm := &Communicator{ 22 Chroot: 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 *StepChrootProvision) Cleanup(state multistep.StateBag) {}