github.com/rothwerx/packer@v0.9.0/builder/vmware/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 VNCPortMin uint `mapstructure:"vnc_port_min"` 15 VNCPortMax uint `mapstructure:"vnc_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.VNCPortMin == 0 { 26 c.VNCPortMin = 5900 27 } 28 29 if c.VNCPortMax == 0 { 30 c.VNCPortMax = 6000 31 } 32 33 var errs []error 34 var err error 35 if c.RawBootWait != "" { 36 c.BootWait, err = time.ParseDuration(c.RawBootWait) 37 if err != nil { 38 errs = append( 39 errs, fmt.Errorf("Failed parsing boot_wait: %s", err)) 40 } 41 } 42 43 if c.VNCPortMin > c.VNCPortMax { 44 errs = append( 45 errs, fmt.Errorf("vnc_port_min must be less than vnc_port_max")) 46 } 47 48 return errs 49 }