2013-11-09 02:43:41 -05:00
|
|
|
package docker
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/mitchellh/multistep"
|
2013-11-12 11:24:16 -05:00
|
|
|
"github.com/mitchellh/packer/common"
|
2013-11-09 02:43:41 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
type StepProvision struct{}
|
|
|
|
|
|
|
|
func (s *StepProvision) Run(state multistep.StateBag) multistep.StepAction {
|
|
|
|
containerId := state.Get("container_id").(string)
|
2015-05-29 12:29:59 -04:00
|
|
|
driver := state.Get("driver").(Driver)
|
2013-11-09 02:43:41 -05:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2013-11-09 02:43:41 -05:00
|
|
|
// Create the communicator that talks to Docker via various
|
|
|
|
// os/exec tricks.
|
|
|
|
comm := &Communicator{
|
|
|
|
ContainerId: containerId,
|
|
|
|
HostDir: tempDir,
|
|
|
|
ContainerDir: "/packer-files",
|
2015-05-29 12:29:59 -04:00
|
|
|
Version: version,
|
2013-11-09 02:43:41 -05:00
|
|
|
}
|
|
|
|
|
2013-11-12 11:24:16 -05:00
|
|
|
prov := common.StepProvision{Comm: comm}
|
|
|
|
return prov.Run(state)
|
2013-11-09 02:43:41 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
func (s *StepProvision) Cleanup(state multistep.StateBag) {}
|