github.com/jerryclinesmith/packer@v0.3.7/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  
    19  	// Create our communicator
    20  	comm := &Communicator{
    21  		Chroot: mountPath,
    22  	}
    23  
    24  	// Provision
    25  	log.Println("Running the provision hook")
    26  	if err := hook.Run(packer.HookProvision, ui, comm, nil); err != nil {
    27  		state.Put("error", err)
    28  		return multistep.ActionHalt
    29  	}
    30  
    31  	return multistep.ActionContinue
    32  }
    33  
    34  func (s *StepChrootProvision) Cleanup(state multistep.StateBag) {}