2014-04-06 13:21:22 -04:00
|
|
|
package common
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"time"
|
2015-05-27 16:49:31 -04:00
|
|
|
|
2017-04-04 16:39:01 -04:00
|
|
|
"github.com/hashicorp/packer/template/interpolate"
|
2014-04-06 13:21:22 -04:00
|
|
|
)
|
|
|
|
|
2016-12-16 14:51:55 -05:00
|
|
|
// RunConfig contains the configuration for VM run.
|
2014-04-06 13:21:22 -04:00
|
|
|
type RunConfig struct {
|
|
|
|
RawBootWait string `mapstructure:"boot_wait"`
|
|
|
|
|
|
|
|
BootWait time.Duration ``
|
|
|
|
}
|
|
|
|
|
2016-12-16 14:51:55 -05:00
|
|
|
// Prepare sets the configuration for VM run.
|
2015-05-27 16:49:31 -04:00
|
|
|
func (c *RunConfig) Prepare(ctx *interpolate.Context) []error {
|
2014-04-06 13:21:22 -04:00
|
|
|
if c.RawBootWait == "" {
|
|
|
|
c.RawBootWait = "10s"
|
|
|
|
}
|
|
|
|
|
|
|
|
var err error
|
|
|
|
c.BootWait, err = time.ParseDuration(c.RawBootWait)
|
|
|
|
if err != nil {
|
2015-05-27 16:49:31 -04:00
|
|
|
return []error{fmt.Errorf("Failed parsing boot_wait: %s", err)}
|
2014-04-06 13:21:22 -04:00
|
|
|
}
|
|
|
|
|
2015-05-27 16:49:31 -04:00
|
|
|
return nil
|
2014-04-06 13:21:22 -04:00
|
|
|
}
|