2019-05-31 08:27:41 -04:00
|
|
|
//go:generate struct-markdown
|
|
|
|
|
2013-12-22 13:30:12 -05:00
|
|
|
package common
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2014-09-05 14:52:55 -04:00
|
|
|
|
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 {
|
2019-05-28 11:50:58 -04:00
|
|
|
// Packer defaults to building VirtualBox virtual
|
|
|
|
// machines by launching a GUI that shows the console of the machine
|
|
|
|
// being built. When this value is set to true, the machine will start
|
|
|
|
// without a console.
|
|
|
|
Headless bool `mapstructure:"headless" required:"false"`
|
|
|
|
// The IP address that should be
|
|
|
|
// binded to for VRDP. By default packer will use 127.0.0.1 for this. If you
|
|
|
|
// wish to bind to all interfaces use 0.0.0.0.
|
|
|
|
VRDPBindAddress string `mapstructure:"vrdp_bind_address" required:"false"`
|
|
|
|
// The minimum and maximum port
|
|
|
|
// to use for VRDP access to the virtual machine. Packer uses a randomly chosen
|
|
|
|
// port in this range that appears available. By default this is 5900 to
|
|
|
|
// 6000. The minimum and maximum ports are inclusive.
|
|
|
|
VRDPPortMin int `mapstructure:"vrdp_port_min" required:"false"`
|
2019-03-19 09:47:21 -04:00
|
|
|
VRDPPortMax int `mapstructure:"vrdp_port_max"`
|
2013-12-22 13:30:12 -05:00
|
|
|
}
|
|
|
|
|
2018-04-18 19:19:44 -04:00
|
|
|
func (c *RunConfig) Prepare(ctx *interpolate.Context) (errs []error) {
|
2016-05-23 09:24:16 -04:00
|
|
|
if c.VRDPBindAddress == "" {
|
|
|
|
c.VRDPBindAddress = "127.0.0.1"
|
|
|
|
}
|
|
|
|
|
2015-08-22 18:41:08 -04:00
|
|
|
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"))
|
|
|
|
}
|
|
|
|
|
2018-04-18 19:19:44 -04:00
|
|
|
return
|
2013-12-22 13:30:12 -05:00
|
|
|
}
|