Commit e69bb185 authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

builder/virtualbox/ovf: specify name for import

parent 5b223f07
......@@ -48,6 +48,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
Files: b.config.FloppyFiles,
},
&StepImport{
Name: b.config.VMName,
SourcePath: b.config.SourcePath,
},
/*
......
package ovf
import (
"fmt"
vboxcommon "github.com/mitchellh/packer/builder/virtualbox/common"
"github.com/mitchellh/packer/common"
"github.com/mitchellh/packer/packer"
......@@ -19,6 +20,7 @@ type Config struct {
vboxcommon.VBoxVersionConfig `mapstructure:",squash"`
SourcePath string `mapstructure:"source_path"`
VMName string `mapstructure:"vm_name"`
tpl *packer.ConfigTemplate
}
......@@ -36,6 +38,11 @@ func NewConfig(raws ...interface{}) (*Config, []string, error) {
}
c.tpl.UserVars = c.PackerUserVars
// Defaults
if c.VMName == "" {
c.VMName = fmt.Sprintf("packer-%s-{{timestamp}}", c.PackerBuildName)
}
// Prepare the errors
errs := common.CheckUnusedConfig(md)
errs = packer.MultiErrorAppend(errs, c.ExportConfig.Prepare(c.tpl)...)
......@@ -46,6 +53,19 @@ func NewConfig(raws ...interface{}) (*Config, []string, error) {
errs = packer.MultiErrorAppend(errs, c.VBoxManageConfig.Prepare(c.tpl)...)
errs = packer.MultiErrorAppend(errs, c.VBoxVersionConfig.Prepare(c.tpl)...)
templates := map[string]*string{
"vm_name": &c.VMName,
}
for n, ptr := range templates {
var err error
*ptr, err = c.tpl.Process(*ptr, nil)
if err != nil {
errs = packer.MultiErrorAppend(
errs, fmt.Errorf("Error processing %s: %s", n, err))
}
}
// Warnings
var warnings []string
if c.ShutdownCommand == "" {
......
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