packer-cn/builder/virtualbox/common/run_config.go

37 lines
706 B
Go
Raw Normal View History

2013-12-22 13:30:12 -05:00
package common
import (
"fmt"
2017-04-04 16:39:01 -04:00
"github.com/hashicorp/packer/template/interpolate"
2013-12-22 13:30:12 -05:00
)
type RunConfig struct {
Headless bool `mapstructure:"headless"`
2013-12-22 13:30:12 -05:00
VRDPBindAddress string `mapstructure:"vrdp_bind_address"`
VRDPPortMin uint `mapstructure:"vrdp_port_min"`
VRDPPortMax uint `mapstructure:"vrdp_port_max"`
2013-12-22 13:30:12 -05:00
}
func (c *RunConfig) Prepare(ctx *interpolate.Context) (errs []error) {
if c.VRDPBindAddress == "" {
c.VRDPBindAddress = "127.0.0.1"
}
if c.VRDPPortMin == 0 {
c.VRDPPortMin = 5900
}
if c.VRDPPortMax == 0 {
c.VRDPPortMax = 6000
}
if c.VRDPPortMin > c.VRDPPortMax {
errs = append(
errs, fmt.Errorf("vrdp_port_min must be less than vrdp_port_max"))
}
return
2013-12-22 13:30:12 -05:00
}