This commit is contained in:
Matthew Hooker 2017-03-15 16:52:58 -07:00
parent 286fe78bfc
commit 262c8dc24a
No known key found for this signature in database
GPG Key ID: 7B5F933D9CE8C6A1
2 changed files with 22 additions and 1 deletions

View File

@ -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)

View File

@ -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,
} }
} }