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