Merge pull request #4672 from mitchellh/4670
show correct step name when debugging
This commit is contained in:
commit
56d73a5b83
|
@ -61,6 +61,10 @@ type abortStep struct {
|
||||||
ui packer.Ui
|
ui packer.Ui
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s abortStep) InnerStepName() string {
|
||||||
|
return typeName(s.step)
|
||||||
|
}
|
||||||
|
|
||||||
func (s abortStep) Run(state multistep.StateBag) multistep.StepAction {
|
func (s abortStep) Run(state multistep.StateBag) multistep.StepAction {
|
||||||
return s.step.Run(state)
|
return s.step.Run(state)
|
||||||
}
|
}
|
||||||
|
@ -82,6 +86,10 @@ type askStep struct {
|
||||||
ui packer.Ui
|
ui packer.Ui
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s askStep) InnerStepName() string {
|
||||||
|
return typeName(s.step)
|
||||||
|
}
|
||||||
|
|
||||||
func (s askStep) Run(state multistep.StateBag) (action multistep.StepAction) {
|
func (s askStep) Run(state multistep.StateBag) (action multistep.StepAction) {
|
||||||
for {
|
for {
|
||||||
action = s.step.Run(state)
|
action = s.step.Run(state)
|
||||||
|
|
|
@ -17,6 +17,13 @@ const (
|
||||||
DebugLocationBeforeCleanup
|
DebugLocationBeforeCleanup
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// StepWrapper is an interface that wrapped steps can implement to expose their
|
||||||
|
// inner step names to the debug runner.
|
||||||
|
type StepWrapper interface {
|
||||||
|
// InnerStepName should return the human readable name of the wrapped step.
|
||||||
|
InnerStepName() string
|
||||||
|
}
|
||||||
|
|
||||||
// DebugPauseFn is the type signature for the function that is called
|
// DebugPauseFn is the type signature for the function that is called
|
||||||
// whenever the DebugRunner pauses. It allows the caller time to
|
// whenever the DebugRunner pauses. It allows the caller time to
|
||||||
// inspect the state of the multi-step sequence at a given step.
|
// inspect the state of the multi-step sequence at a given step.
|
||||||
|
@ -56,8 +63,14 @@ func (r *DebugRunner) Run(state StateBag) {
|
||||||
steps := make([]Step, len(r.Steps)*2)
|
steps := make([]Step, len(r.Steps)*2)
|
||||||
for i, step := range r.Steps {
|
for i, step := range r.Steps {
|
||||||
steps[i*2] = step
|
steps[i*2] = step
|
||||||
|
name := ""
|
||||||
|
if wrapped, ok := step.(StepWrapper); ok {
|
||||||
|
name = wrapped.InnerStepName()
|
||||||
|
} else {
|
||||||
|
name = reflect.Indirect(reflect.ValueOf(step)).Type().Name()
|
||||||
|
}
|
||||||
steps[(i*2)+1] = &debugStepPause{
|
steps[(i*2)+1] = &debugStepPause{
|
||||||
reflect.Indirect(reflect.ValueOf(step)).Type().Name(),
|
name,
|
||||||
pauseFn,
|
pauseFn,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -633,9 +633,10 @@
|
||||||
"revision": "281073eb9eb092240d33ef253c404f1cca550309"
|
"revision": "281073eb9eb092240d33ef253c404f1cca550309"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"checksumSHA1": "9Vh2o3Vs6HzI8P04ks4kvIpegco=",
|
"checksumSHA1": "5x1RX5m8SCkCRLyLL8wBc0qJpV8=",
|
||||||
"path": "github.com/mitchellh/multistep",
|
"path": "github.com/mitchellh/multistep",
|
||||||
"revision": "162146fc57112954184d90266f4733e900ed05a5"
|
"revision": "391576a156a54cfbb4cf5d5eda40cf6ffa3e3a4d",
|
||||||
|
"revisionTime": "2017-03-16T18:53:39Z"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"checksumSHA1": "VBo7ciCNRr7wNVFmBTW8sm4PQ14=",
|
"checksumSHA1": "VBo7ciCNRr7wNVFmBTW8sm4PQ14=",
|
||||||
|
|
Loading…
Reference in New Issue