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

37 lines
1.1 KiB
Go
Raw Normal View History

//go:generate struct-markdown
2013-12-22 14:50:29 -05:00
package common
import (
"fmt"
2017-04-04 16:39:01 -04:00
"github.com/hashicorp/packer/template/interpolate"
2013-12-22 14:50:29 -05:00
)
type VBoxVersionConfig struct {
2019-06-06 10:29:25 -04:00
Communicator string `mapstructure:"communicator"`
// The path within the virtual machine to
2019-06-06 10:29:25 -04:00
// upload a file that contains the VirtualBox version that was used to create
// the machine. This information can be useful for provisioning. By default
// this is .vbox_version, which will generally be upload it into the
// home directory. Set to an empty string to skip uploading this file, which
// can be useful when using the none communicator.
VBoxVersionFile *string `mapstructure:"virtualbox_version_file" required:"false"`
2013-12-22 14:50:29 -05:00
}
func (c *VBoxVersionConfig) Prepare(ctx *interpolate.Context) []error {
var errs []error
if c.VBoxVersionFile == nil {
default_file := ".vbox_version"
c.VBoxVersionFile = &default_file
2013-12-22 14:50:29 -05:00
}
if c.Communicator == "none" && *c.VBoxVersionFile != "" {
errs = append(errs, fmt.Errorf("virtualbox_version_file has to be an "+
"empty string when communicator = 'none'."))
}
return errs
2013-12-22 14:50:29 -05:00
}