2015-11-01 17:29:24 -05:00
|
|
|
package common
|
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
|
2017-04-04 16:39:01 -04:00
|
|
|
"github.com/hashicorp/packer/template/interpolate"
|
2015-11-01 17:29:24 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
// HTTPConfig contains configuration for the local HTTP Server
|
|
|
|
type HTTPConfig struct {
|
|
|
|
HTTPDir string `mapstructure:"http_directory"`
|
2019-03-15 11:25:45 -04:00
|
|
|
HTTPPortMin int `mapstructure:"http_port_min"`
|
|
|
|
HTTPPortMax int `mapstructure:"http_port_max"`
|
2015-11-01 17:29:24 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
func (c *HTTPConfig) Prepare(ctx *interpolate.Context) []error {
|
|
|
|
// Validation
|
|
|
|
var errs []error
|
|
|
|
|
|
|
|
if c.HTTPPortMin == 0 {
|
|
|
|
c.HTTPPortMin = 8000
|
|
|
|
}
|
|
|
|
|
|
|
|
if c.HTTPPortMax == 0 {
|
|
|
|
c.HTTPPortMax = 9000
|
|
|
|
}
|
|
|
|
|
|
|
|
if c.HTTPPortMin > c.HTTPPortMax {
|
|
|
|
errs = append(errs,
|
|
|
|
errors.New("http_port_min must be less than http_port_max"))
|
|
|
|
}
|
|
|
|
|
|
|
|
return errs
|
|
|
|
}
|