github.com/rothwerx/packer@v0.9.0/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  	config := state.Get("config").(*Config)
    11  	containerId := state.Get("container_id").(string)
    12  	driver := state.Get("driver").(Driver)
    13  	tempDir := state.Get("temp_dir").(string)
    14  
    15  	// Get the version so we can pass it to the communicator
    16  	version, err := driver.Version()
    17  	if err != nil {
    18  		state.Put("error", err)
    19  		return multistep.ActionHalt
    20  	}
    21  
    22  	// Create the communicator that talks to Docker via various
    23  	// os/exec tricks.
    24  	comm := &Communicator{
    25  		ContainerId:  containerId,
    26  		HostDir:      tempDir,
    27  		ContainerDir: "/packer-files",
    28  		Version:      version,
    29  		Config:       config,
    30  	}
    31  
    32  	state.Put("communicator", comm)
    33  	return multistep.ActionContinue
    34  }
    35  
    36  func (s *StepConnectDocker) Cleanup(state multistep.StateBag) {}