Commit f754c171 authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

builder/*: Add support for debug

parent 22e73451
...@@ -12,6 +12,7 @@ import ( ...@@ -12,6 +12,7 @@ import (
"github.com/mitchellh/goamz/ec2" "github.com/mitchellh/goamz/ec2"
"github.com/mitchellh/mapstructure" "github.com/mitchellh/mapstructure"
"github.com/mitchellh/multistep" "github.com/mitchellh/multistep"
"github.com/mitchellh/packer/builder/common"
"github.com/mitchellh/packer/packer" "github.com/mitchellh/packer/packer"
"log" "log"
"time" "time"
...@@ -36,6 +37,7 @@ type config struct { ...@@ -36,6 +37,7 @@ type config struct {
// Configuration of the resulting AMI // Configuration of the resulting AMI
AMIName string `mapstructure:"ami_name"` AMIName string `mapstructure:"ami_name"`
PackerDebug bool `mapstructure:"packer_debug"`
RawSSHTimeout string `mapstructure:"ssh_timeout"` RawSSHTimeout string `mapstructure:"ssh_timeout"`
} }
...@@ -132,7 +134,15 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe ...@@ -132,7 +134,15 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
} }
// Run! // Run!
if b.config.PackerDebug {
b.runner = &multistep.DebugRunner{
Steps: steps,
PauseFn: common.MultistepDebugFn(ui),
}
} else {
b.runner = &multistep.BasicRunner{Steps: steps} b.runner = &multistep.BasicRunner{Steps: steps}
}
b.runner.Run(state) b.runner.Run(state)
// If there are no AMIs, then jsut return // If there are no AMIs, then jsut return
......
...@@ -5,6 +5,7 @@ import ( ...@@ -5,6 +5,7 @@ import (
"fmt" "fmt"
"github.com/mitchellh/mapstructure" "github.com/mitchellh/mapstructure"
"github.com/mitchellh/multistep" "github.com/mitchellh/multistep"
"github.com/mitchellh/packer/builder/common"
"github.com/mitchellh/packer/packer" "github.com/mitchellh/packer/packer"
"log" "log"
"net/url" "net/url"
...@@ -42,6 +43,8 @@ type config struct { ...@@ -42,6 +43,8 @@ type config struct {
SSHWaitTimeout time.Duration `` SSHWaitTimeout time.Duration ``
VMName string `mapstructure:"vm_name"` VMName string `mapstructure:"vm_name"`
PackerDebug bool `mapstructure:"packer_debug"`
RawBootWait string `mapstructure:"boot_wait"` RawBootWait string `mapstructure:"boot_wait"`
RawShutdownTimeout string `mapstructure:"shutdown_timeout"` RawShutdownTimeout string `mapstructure:"shutdown_timeout"`
RawSSHWaitTimeout string `mapstructure:"ssh_wait_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 ...@@ -212,7 +215,15 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
state["ui"] = ui state["ui"] = ui
// Run // Run
if b.config.PackerDebug {
b.runner = &multistep.DebugRunner{
Steps: steps,
PauseFn: common.MultistepDebugFn(ui),
}
} else {
b.runner = &multistep.BasicRunner{Steps: steps} b.runner = &multistep.BasicRunner{Steps: steps}
}
b.runner.Run(state) b.runner.Run(state)
return nil, nil return nil, nil
......
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