Commit 93bb0d86 authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

builder/virtualbox: fix default names

parent 84189f7a
...@@ -57,9 +57,6 @@ type Config struct { ...@@ -57,9 +57,6 @@ type Config struct {
} }
func (b *Builder) Prepare(raws ...interface{}) ([]string, error) { func (b *Builder) Prepare(raws ...interface{}) ([]string, error) {
// Set some defaults
b.config.VMName = fmt.Sprintf("packer-%s-{{timestamp}}", b.config.PackerBuildName)
err := config.Decode(&b.config, &config.DecodeOpts{ err := config.Decode(&b.config, &config.DecodeOpts{
Interpolate: true, Interpolate: true,
InterpolateContext: &b.config.ctx, InterpolateContext: &b.config.ctx,
...@@ -116,6 +113,11 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) { ...@@ -116,6 +113,11 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) {
b.config.ISOInterface = "ide" b.config.ISOInterface = "ide"
} }
if b.config.VMName == "" {
b.config.VMName = fmt.Sprintf(
"packer-%s-%d", b.config.PackerBuildName, interpolate.InitTime.Unix())
}
if b.config.HardDriveInterface != "ide" && b.config.HardDriveInterface != "sata" && b.config.HardDriveInterface != "scsi" { if b.config.HardDriveInterface != "ide" && b.config.HardDriveInterface != "sata" && b.config.HardDriveInterface != "scsi" {
errs = packer.MultiErrorAppend( errs = packer.MultiErrorAppend(
errs, errors.New("hard_drive_interface can only be ide, sata, or scsi")) errs, errors.New("hard_drive_interface can only be ide, sata, or scsi"))
......
...@@ -66,8 +66,10 @@ func NewConfig(raws ...interface{}) (*Config, []string, error) { ...@@ -66,8 +66,10 @@ func NewConfig(raws ...interface{}) (*Config, []string, error) {
if c.GuestAdditionsPath == "" { if c.GuestAdditionsPath == "" {
c.GuestAdditionsPath = "VBoxGuestAdditions.iso" c.GuestAdditionsPath = "VBoxGuestAdditions.iso"
} }
if c.VMName == "" { if c.VMName == "" {
c.VMName = fmt.Sprintf("packer-%s-{{timestamp}}", c.PackerBuildName) c.VMName = fmt.Sprintf(
"packer-%s-%d", c.PackerBuildName, interpolate.InitTime.Unix())
} }
// Prepare the errors // Prepare the errors
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment