2013-12-26 15:26:09 -07:00
|
|
|
package common
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
2017-04-04 13:39:01 -07:00
|
|
|
"github.com/hashicorp/packer/template/interpolate"
|
2013-12-26 15:26:09 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
type RunConfig struct {
|
2018-04-18 14:10:28 -07:00
|
|
|
Headless bool `mapstructure:"headless"`
|
2013-12-26 15:26:09 -07:00
|
|
|
|
2016-08-19 12:49:23 +02:00
|
|
|
VNCBindAddress string `mapstructure:"vnc_bind_address"`
|
|
|
|
VNCPortMin uint `mapstructure:"vnc_port_min"`
|
|
|
|
VNCPortMax uint `mapstructure:"vnc_port_max"`
|
|
|
|
VNCDisablePassword bool `mapstructure:"vnc_disable_password"`
|
2013-12-26 15:26:09 -07:00
|
|
|
}
|
|
|
|
|
2018-04-18 14:10:28 -07:00
|
|
|
func (c *RunConfig) Prepare(ctx *interpolate.Context) (errs []error) {
|
2014-09-05 12:10:40 -07:00
|
|
|
if c.VNCPortMin == 0 {
|
|
|
|
c.VNCPortMin = 5900
|
|
|
|
}
|
|
|
|
|
|
|
|
if c.VNCPortMax == 0 {
|
|
|
|
c.VNCPortMax = 6000
|
|
|
|
}
|
|
|
|
|
2016-05-23 14:02:56 +01:00
|
|
|
if c.VNCBindAddress == "" {
|
|
|
|
c.VNCBindAddress = "127.0.0.1"
|
|
|
|
}
|
|
|
|
|
2014-09-05 12:10:40 -07:00
|
|
|
if c.VNCPortMin > c.VNCPortMax {
|
2018-04-18 14:10:28 -07:00
|
|
|
errs = append(errs, fmt.Errorf("vnc_port_min must be less than vnc_port_max"))
|
2014-09-05 12:10:40 -07:00
|
|
|
}
|
|
|
|
|
2018-04-18 14:10:28 -07:00
|
|
|
return
|
2013-12-26 15:26:09 -07:00
|
|
|
}
|