Commit 21bb0674 authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

builder/docker: ctrl-C works during provisioning

parent d88cb09d
...@@ -2,16 +2,14 @@ package docker ...@@ -2,16 +2,14 @@ package docker
import ( import (
"github.com/mitchellh/multistep" "github.com/mitchellh/multistep"
"github.com/mitchellh/packer/packer" "github.com/mitchellh/packer/common"
) )
type StepProvision struct{} type StepProvision struct{}
func (s *StepProvision) Run(state multistep.StateBag) multistep.StepAction { func (s *StepProvision) Run(state multistep.StateBag) multistep.StepAction {
containerId := state.Get("container_id").(string) containerId := state.Get("container_id").(string)
hook := state.Get("hook").(packer.Hook)
tempDir := state.Get("temp_dir").(string) tempDir := state.Get("temp_dir").(string)
ui := state.Get("ui").(packer.Ui)
// Create the communicator that talks to Docker via various // Create the communicator that talks to Docker via various
// os/exec tricks. // os/exec tricks.
...@@ -21,13 +19,8 @@ func (s *StepProvision) Run(state multistep.StateBag) multistep.StepAction { ...@@ -21,13 +19,8 @@ func (s *StepProvision) Run(state multistep.StateBag) multistep.StepAction {
ContainerDir: "/packer-files", ContainerDir: "/packer-files",
} }
// Run the provisioning hook prov := common.StepProvision{Comm: comm}
if err := hook.Run(packer.HookProvision, ui, comm, nil); err != nil { return prov.Run(state)
state.Put("error", err)
return multistep.ActionHalt
}
return multistep.ActionContinue
} }
func (s *StepProvision) Cleanup(state multistep.StateBag) {} func (s *StepProvision) Cleanup(state multistep.StateBag) {}
...@@ -16,10 +16,16 @@ import ( ...@@ -16,10 +16,16 @@ import (
// //
// Produces: // Produces:
// <nothing> // <nothing>
type StepProvision struct{} type StepProvision struct {
Comm packer.Communicator
}
func (s *StepProvision) Run(state multistep.StateBag) multistep.StepAction {
comm := s.Comm
if comm == nil {
comm = state.Get("communicator").(packer.Communicator)
}
func (*StepProvision) Run(state multistep.StateBag) multistep.StepAction {
comm := state.Get("communicator").(packer.Communicator)
hook := state.Get("hook").(packer.Hook) hook := state.Get("hook").(packer.Hook)
ui := state.Get("ui").(packer.Ui) ui := state.Get("ui").(packer.Ui)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment