github.com/emate/packer@v0.8.1-0.20150625195101-fe0fde195dc6/builder/docker/step_connect_docker.go (about)

     1  package docker
     2  
     3  import (
     4  	"github.com/mitchellh/multistep"
     5  )
     6  
     7  type StepConnectDocker struct{}
     8  
     9  func (s *StepConnectDocker) Run(state multistep.StateBag) multistep.StepAction {
    10  	containerId := state.Get("container_id").(string)
    11  	driver := state.Get("driver").(Driver)
    12  	tempDir := state.Get("temp_dir").(string)
    13  
    14  	// Get the version so we can pass it to the communicator
    15  	version, err := driver.Version()
    16  	if err != nil {
    17  		state.Put("error", err)
    18  		return multistep.ActionHalt
    19  	}
    20  
    21  	// Create the communicator that talks to Docker via various
    22  	// os/exec tricks.
    23  	comm := &Communicator{
    24  		ContainerId:  containerId,
    25  		HostDir:      tempDir,
    26  		ContainerDir: "/packer-files",
    27  		Version:      version,
    28  	}
    29  
    30  	state.Put("communicator", comm)
    31  	return multistep.ActionContinue
    32  }
    33  
    34  func (s *StepConnectDocker) Cleanup(state multistep.StateBag) {}