2015-06-21 07:36:07 -04:00
|
|
|
package common
|
|
|
|
|
|
|
|
import (
|
2018-01-22 18:32:33 -05:00
|
|
|
"context"
|
2015-06-21 07:36:07 -04:00
|
|
|
"fmt"
|
2018-01-22 18:32:33 -05:00
|
|
|
"time"
|
|
|
|
|
2018-01-19 19:18:44 -05:00
|
|
|
"github.com/hashicorp/packer/helper/multistep"
|
2017-04-04 16:39:01 -04:00
|
|
|
"github.com/hashicorp/packer/packer"
|
2015-06-21 07:36:07 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
type StepSleep struct {
|
2016-11-06 11:02:00 -05:00
|
|
|
Minutes time.Duration
|
2015-06-21 07:36:07 -04:00
|
|
|
ActionName string
|
|
|
|
}
|
|
|
|
|
2019-03-29 11:50:02 -04:00
|
|
|
func (s *StepSleep) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction {
|
2015-06-21 07:36:07 -04:00
|
|
|
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...")
|
2015-06-21 07:36:07 -04:00
|
|
|
}
|
2016-11-06 11:02:00 -05:00
|
|
|
time.Sleep(time.Minute * s.Minutes)
|
2015-06-21 07:36:07 -04:00
|
|
|
|
|
|
|
return multistep.ActionContinue
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *StepSleep) Cleanup(state multistep.StateBag) {
|
|
|
|
|
|
|
|
}
|