github.com/rothwerx/packer@v0.9.0/builder/virtualbox/common/run_config.go (about) 1 package common 2 3 import ( 4 "fmt" 5 "time" 6 7 "github.com/mitchellh/packer/template/interpolate" 8 ) 9 10 type RunConfig struct { 11 Headless bool `mapstructure:"headless"` 12 RawBootWait string `mapstructure:"boot_wait"` 13 14 VRDPPortMin uint `mapstructure:"vrdp_port_min"` 15 VRDPPortMax uint `mapstructure:"vrdp_port_max"` 16 17 BootWait time.Duration `` 18 } 19 20 func (c *RunConfig) Prepare(ctx *interpolate.Context) []error { 21 if c.RawBootWait == "" { 22 c.RawBootWait = "10s" 23 } 24 25 if c.VRDPPortMin == 0 { 26 c.VRDPPortMin = 5900 27 } 28 29 if c.VRDPPortMax == 0 { 30 c.VRDPPortMax = 6000 31 } 32 33 var errs []error 34 var err error 35 c.BootWait, err = time.ParseDuration(c.RawBootWait) 36 if err != nil { 37 errs = append(errs, fmt.Errorf("Failed parsing boot_wait: %s", err)) 38 } 39 40 if c.VRDPPortMin > c.VRDPPortMax { 41 errs = append( 42 errs, fmt.Errorf("vrdp_port_min must be less than vrdp_port_max")) 43 } 44 45 return errs 46 }