github.com/marksheahan/packer@v0.10.2-0.20160613200515-1acb2d6645a0/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 VNCBindAddress string `mapstructure:"vnc_bind_address"` 15 VNCPortMin uint `mapstructure:"vnc_port_min"` 16 VNCPortMax uint `mapstructure:"vnc_port_max"` 17 18 BootWait time.Duration `` 19 } 20 21 func (c *RunConfig) Prepare(ctx *interpolate.Context) []error { 22 if c.RawBootWait == "" { 23 c.RawBootWait = "10s" 24 } 25 26 if c.VNCPortMin == 0 { 27 c.VNCPortMin = 5900 28 } 29 30 if c.VNCPortMax == 0 { 31 c.VNCPortMax = 6000 32 } 33 34 if c.VNCBindAddress == "" { 35 c.VNCBindAddress = "127.0.0.1" 36 } 37 38 var errs []error 39 var err error 40 if c.RawBootWait != "" { 41 c.BootWait, err = time.ParseDuration(c.RawBootWait) 42 if err != nil { 43 errs = append( 44 errs, fmt.Errorf("Failed parsing boot_wait: %s", err)) 45 } 46 } 47 48 if c.VNCPortMin > c.VNCPortMax { 49 errs = append( 50 errs, fmt.Errorf("vnc_port_min must be less than vnc_port_max")) 51 } 52 53 return errs 54 }