github.phpd.cn/hashicorp/packer@v1.3.2/builder/virtualbox/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 VRDPBindAddress string `mapstructure:"vrdp_bind_address"` 13 VRDPPortMin uint `mapstructure:"vrdp_port_min"` 14 VRDPPortMax uint `mapstructure:"vrdp_port_max"` 15 } 16 17 func (c *RunConfig) Prepare(ctx *interpolate.Context) (errs []error) { 18 if c.VRDPBindAddress == "" { 19 c.VRDPBindAddress = "127.0.0.1" 20 } 21 22 if c.VRDPPortMin == 0 { 23 c.VRDPPortMin = 5900 24 } 25 26 if c.VRDPPortMax == 0 { 27 c.VRDPPortMax = 6000 28 } 29 30 if c.VRDPPortMin > c.VRDPPortMax { 31 errs = append( 32 errs, fmt.Errorf("vrdp_port_min must be less than vrdp_port_max")) 33 } 34 35 return 36 }