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

37 lines
763 B
Go
Raw Normal View History

2013-12-26 17:26:09 -05:00
package common
import (
"fmt"
2017-04-04 16:39:01 -04:00
"github.com/hashicorp/packer/template/interpolate"
2013-12-26 17:26:09 -05:00
)
type RunConfig struct {
Headless bool `mapstructure:"headless"`
2013-12-26 17:26:09 -05:00
VNCBindAddress string `mapstructure:"vnc_bind_address"`
2019-03-19 09:47:21 -04:00
VNCPortMin int `mapstructure:"vnc_port_min"`
VNCPortMax int `mapstructure:"vnc_port_max"`
VNCDisablePassword bool `mapstructure:"vnc_disable_password"`
2013-12-26 17:26:09 -05:00
}
func (c *RunConfig) Prepare(ctx *interpolate.Context) (errs []error) {
2014-09-05 15:10:40 -04:00
if c.VNCPortMin == 0 {
c.VNCPortMin = 5900
}
if c.VNCPortMax == 0 {
c.VNCPortMax = 6000
}
if c.VNCBindAddress == "" {
c.VNCBindAddress = "127.0.0.1"
}
2014-09-05 15:10:40 -04:00
if c.VNCPortMin > c.VNCPortMax {
errs = append(errs, fmt.Errorf("vnc_port_min must be less than vnc_port_max"))
2014-09-05 15:10:40 -04:00
}
return
2013-12-26 17:26:09 -05:00
}