packer-cn/builder/docker/step_provision.go

36 lines
861 B
Go
Raw Normal View History

package docker
import (
"github.com/mitchellh/multistep"
"github.com/mitchellh/packer/common"
)
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)
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,
ContainerDir: "/packer-files",
2015-05-29 12:29:59 -04:00
Version: version,
}
prov := common.StepProvision{Comm: comm}
return prov.Run(state)
}
func (s *StepProvision) Cleanup(state multistep.StateBag) {}