Add nullStep as return for multistep.If (#10247)
This change introduces a new nullStep type that can be used in place of a nil step. This fixes an issue where multistep.If would return a nil step if the condition was not met causing a builder to crash when executed using `-on-error=ask` or `-on-error=abort`. Closes #10241
This commit is contained in:
parent
f44e912072
commit
67e2c0b83c
|
@ -3,7 +3,7 @@ package multistep
|
|||
// if returns step only if on is true.
|
||||
func If(on bool, step Step) Step {
|
||||
if on == false {
|
||||
return nil
|
||||
return &nullStep{}
|
||||
}
|
||||
return step
|
||||
}
|
||||
|
|
|
@ -61,3 +61,11 @@ type Runner interface {
|
|||
// Run runs the steps with the given initial state.
|
||||
Run(context.Context, StateBag)
|
||||
}
|
||||
|
||||
type nullStep struct{}
|
||||
|
||||
func (s nullStep) Run(ctx context.Context, state StateBag) StepAction {
|
||||
return ActionContinue
|
||||
}
|
||||
|
||||
func (s nullStep) Cleanup(state StateBag) {}
|
||||
|
|
Loading…
Reference in New Issue