packer-cn/builder/virtualbox/common/export_config.go

30 lines
604 B
Go
Raw Normal View History

//go:generate struct-markdown
2013-12-22 10:40:39 -08:00
package common
import (
"errors"
2017-04-04 13:39:01 -07:00
"github.com/hashicorp/packer/template/interpolate"
2013-12-22 10:40:39 -08:00
)
type ExportConfig struct {
// Either ovf or ova, this specifies the output format
2019-06-06 16:29:25 +02:00
// of the exported virtual machine. This defaults to ovf.
Format string `mapstructure:"format" required:"false"`
2013-12-22 10:40:39 -08:00
}
func (c *ExportConfig) Prepare(ctx *interpolate.Context) []error {
2013-12-22 10:40:39 -08:00
if c.Format == "" {
c.Format = "ovf"
}
var errs []error
2013-12-22 10:40:39 -08:00
if c.Format != "ovf" && c.Format != "ova" {
errs = append(errs,
errors.New("invalid format, only 'ovf' or 'ova' are allowed"))
}
return errs
}