github.phpd.cn/hashicorp/packer@v1.3.2/builder/vmware/common/run_config.go (about) 1 package common 2 3 import ( 4 "fmt" 5 6 "github.com/hashicorp/packer/template/interpolate" 7 ) 8 9 type RunConfig struct { 10 Headless bool `mapstructure:"headless"` 11 12 VNCBindAddress string `mapstructure:"vnc_bind_address"` 13 VNCPortMin uint `mapstructure:"vnc_port_min"` 14 VNCPortMax uint `mapstructure:"vnc_port_max"` 15 VNCDisablePassword bool `mapstructure:"vnc_disable_password"` 16 } 17 18 func (c *RunConfig) Prepare(ctx *interpolate.Context) (errs []error) { 19 if c.VNCPortMin == 0 { 20 c.VNCPortMin = 5900 21 } 22 23 if c.VNCPortMax == 0 { 24 c.VNCPortMax = 6000 25 } 26 27 if c.VNCBindAddress == "" { 28 c.VNCBindAddress = "127.0.0.1" 29 } 30 31 if c.VNCPortMin > c.VNCPortMax { 32 errs = append(errs, fmt.Errorf("vnc_port_min must be less than vnc_port_max")) 33 } 34 35 return 36 }