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"`
|
|
|
|
HTTPPortMin uint `mapstructure:"http_port_min"`
|
|
|
|
HTTPPortMax uint `mapstructure:"http_port_max"`
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|