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