packer-cn/builder/docker/step_connect_docker.go

37 lines
904 B
Go
Raw Normal View History

package docker
import (
"github.com/mitchellh/multistep"
)
type StepConnectDocker struct{}
func (s *StepConnectDocker) Run(state multistep.StateBag) multistep.StepAction {
2015-07-16 22:07:39 -04:00
config := state.Get("config").(*Config)
containerId := state.Get("container_id").(string)
2015-05-29 12:29:59 -04:00
driver := state.Get("driver").(Driver)
tempDir := state.Get("temp_dir").(string)
2015-05-29 12:29:59 -04:00
// Get the version so we can pass it to the communicator
version, err := driver.Version()
if err != nil {
state.Put("error", err)
return multistep.ActionHalt
}
// Create the communicator that talks to Docker via various
// os/exec tricks.
comm := &Communicator{
ContainerId: containerId,
HostDir: tempDir,
2017-07-17 12:08:33 -04:00
ContainerDir: config.ContainerDir,
2015-05-29 12:29:59 -04:00
Version: version,
2015-07-27 19:42:06 -04:00
Config: config,
}
state.Put("communicator", comm)
return multistep.ActionContinue
}
func (s *StepConnectDocker) Cleanup(state multistep.StateBag) {}