github.com/mmcquillan/packer@v1.1.1-0.20171009221028-c85cf0483a5d/builder/lxd/step_provision.go (about)

     1  package lxd
     2  
     3  import (
     4  	"github.com/hashicorp/packer/packer"
     5  	"github.com/mitchellh/multistep"
     6  	"log"
     7  )
     8  
     9  // StepProvision provisions the container
    10  type StepProvision struct{}
    11  
    12  func (s *StepProvision) Run(state multistep.StateBag) multistep.StepAction {
    13  	hook := state.Get("hook").(packer.Hook)
    14  	config := state.Get("config").(*Config)
    15  	ui := state.Get("ui").(packer.Ui)
    16  	wrappedCommand := state.Get("wrappedCommand").(CommandWrapper)
    17  
    18  	// Create our communicator
    19  	comm := &Communicator{
    20  		ContainerName: config.ContainerName,
    21  		CmdWrapper:    wrappedCommand,
    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 *StepProvision) Cleanup(state multistep.StateBag) {}