2015-06-21 09:06:27 -04:00
|
|
|
package common
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2017-04-04 16:39:01 -04:00
|
|
|
"github.com/hashicorp/packer/template/interpolate"
|
2015-06-27 17:36:39 -04:00
|
|
|
"time"
|
2015-06-21 09:06:27 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
type RunConfig struct {
|
|
|
|
RawBootWait string `mapstructure:"boot_wait"`
|
|
|
|
|
|
|
|
BootWait time.Duration ``
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *RunConfig) Prepare(ctx *interpolate.Context) []error {
|
|
|
|
if c.RawBootWait == "" {
|
|
|
|
c.RawBootWait = "10s"
|
|
|
|
}
|
|
|
|
|
2015-06-27 17:36:39 -04:00
|
|
|
var errs []error
|
2015-06-21 09:06:27 -04:00
|
|
|
var err error
|
2015-06-27 17:36:39 -04:00
|
|
|
|
|
|
|
if c.RawBootWait != "" {
|
|
|
|
c.BootWait, err = time.ParseDuration(c.RawBootWait)
|
|
|
|
if err != nil {
|
|
|
|
errs = append(
|
|
|
|
errs, fmt.Errorf("Failed parsing boot_wait: %s", err))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return errs
|
2015-06-21 09:06:27 -04:00
|
|
|
}
|