builder/vmware: Use proper pausefn
This commit is contained in:
parent
e0f2bcf8a2
commit
ac029d9ed0
|
@ -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("")
|
||||
}
|
||||
}
|
|
@ -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}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue