builder/vmware: Use proper pausefn

This commit is contained in:
Mitchell Hashimoto 2013-06-14 15:24:53 -07:00
parent e0f2bcf8a2
commit ac029d9ed0
2 changed files with 35 additions and 1 deletions

View File

@ -0,0 +1,30 @@
package common
import (
"fmt"
"github.com/mitchellh/multistep"
"github.com/mitchellh/packer/packer"
)
// MultistepDebugFn will return a proper multistep.DebugPauseFn to
// use for debugging if you're using multistep in your builder.
func MultistepDebugFn(ui packer.Ui) multistep.DebugPauseFn {
return func(loc multistep.DebugLocation, name string, state map[string]interface{}) {
var locationString string
switch loc {
case multistep.DebugLocationAfterRun:
locationString = "after run of"
case multistep.DebugLocationBeforeCleanup:
locationString = "before cleanup of"
default:
locationString = "at"
}
message := fmt.Sprintf(
"Pausing %s step '%s'. Press any key to continue.\n",
locationString, name)
ui.Say(message)
ui.Ask("")
}
}

View File

@ -5,6 +5,7 @@ import (
"fmt"
"github.com/mitchellh/mapstructure"
"github.com/mitchellh/multistep"
"github.com/mitchellh/packer/builder/common"
"github.com/mitchellh/packer/packer"
"log"
"math/rand"
@ -217,7 +218,10 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
// Run!
if b.config.PackerDebug {
b.runner = &multistep.DebugRunner{Steps: steps}
b.runner = &multistep.DebugRunner{
Steps: steps,
PauseFn: common.MultistepDebugFn(ui),
}
} else {
b.runner = &multistep.BasicRunner{Steps: steps}
}