packer-cn/builder/hyperv/common/step_sleep.go

32 lines
646 B
Go
Raw Normal View History

package common
import (
"context"
"fmt"
"time"
2017-04-04 16:39:01 -04:00
"github.com/hashicorp/packer/packer"
2020-11-17 19:31:03 -05:00
"github.com/hashicorp/packer/packer-plugin-sdk/multistep"
)
type StepSleep struct {
2016-11-06 11:02:00 -05:00
Minutes time.Duration
ActionName string
}
func (s *StepSleep) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction {
ui := state.Get("ui").(packer.Ui)
2016-11-06 11:02:00 -05:00
if len(s.ActionName) > 0 {
2018-07-09 12:20:38 -04:00
ui.Say(s.ActionName + "! Waiting for " + fmt.Sprintf("%v", uint(s.Minutes)) +
" minutes to let the action to complete...")
}
2016-11-06 11:02:00 -05:00
time.Sleep(time.Minute * s.Minutes)
return multistep.ActionContinue
}
func (s *StepSleep) Cleanup(state multistep.StateBag) {
}