From f754c171e84308be67c5afff13dfab8013a52360 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sat, 15 Jun 2013 10:51:09 -0700 Subject: [PATCH] builder/*: Add support for debug --- builder/amazonebs/builder.go | 12 +++++++++++- builder/virtualbox/builder.go | 13 ++++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/builder/amazonebs/builder.go b/builder/amazonebs/builder.go index 495f4eea6..b65be2908 100644 --- a/builder/amazonebs/builder.go +++ b/builder/amazonebs/builder.go @@ -12,6 +12,7 @@ import ( "github.com/mitchellh/goamz/ec2" "github.com/mitchellh/mapstructure" "github.com/mitchellh/multistep" + "github.com/mitchellh/packer/builder/common" "github.com/mitchellh/packer/packer" "log" "time" @@ -36,6 +37,7 @@ type config struct { // Configuration of the resulting AMI AMIName string `mapstructure:"ami_name"` + PackerDebug bool `mapstructure:"packer_debug"` RawSSHTimeout string `mapstructure:"ssh_timeout"` } @@ -132,7 +134,15 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe } // Run! - b.runner = &multistep.BasicRunner{Steps: steps} + if b.config.PackerDebug { + b.runner = &multistep.DebugRunner{ + Steps: steps, + PauseFn: common.MultistepDebugFn(ui), + } + } else { + b.runner = &multistep.BasicRunner{Steps: steps} + } + b.runner.Run(state) // If there are no AMIs, then jsut return diff --git a/builder/virtualbox/builder.go b/builder/virtualbox/builder.go index 7a290e0ba..7383e010b 100644 --- a/builder/virtualbox/builder.go +++ b/builder/virtualbox/builder.go @@ -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" "net/url" @@ -42,6 +43,8 @@ type config struct { SSHWaitTimeout time.Duration `` VMName string `mapstructure:"vm_name"` + PackerDebug bool `mapstructure:"packer_debug"` + RawBootWait string `mapstructure:"boot_wait"` RawShutdownTimeout string `mapstructure:"shutdown_timeout"` RawSSHWaitTimeout string `mapstructure:"ssh_wait_timeout"` @@ -212,7 +215,15 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe state["ui"] = ui // Run - b.runner = &multistep.BasicRunner{Steps: steps} + if b.config.PackerDebug { + b.runner = &multistep.DebugRunner{ + Steps: steps, + PauseFn: common.MultistepDebugFn(ui), + } + } else { + b.runner = &multistep.BasicRunner{Steps: steps} + } + b.runner.Run(state) return nil, nil