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 {
|
2018-04-18 19:19:44 -04:00
|
|
|
Headless bool `mapstructure:"headless"`
|
2013-12-22 13:30:12 -05:00
|
|
|
|
2016-05-23 09:24:16 -04:00
|
|
|
VRDPBindAddress string `mapstructure:"vrdp_bind_address"`
|
2019-03-19 09:47:21 -04:00
|
|
|
VRDPPortMin int `mapstructure:"vrdp_port_min"`
|
|
|
|
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
|
|
|
}
|