diff --git a/builder/virtualbox/common/export_opts.go b/builder/virtualbox/common/export_opts.go index 1794823f4..4ae133dcd 100644 --- a/builder/virtualbox/common/export_opts.go +++ b/builder/virtualbox/common/export_opts.go @@ -6,20 +6,20 @@ import ( ) type ExportOpts struct { - ExportOpts string `mapstructure:"export_opts"` + ExportOpts []string `mapstructure:"export_opts"` } func (c *ExportOpts) Prepare(t *packer.ConfigTemplate) []error { - templates := map[string]*string{ - "export_opts": &c.ExportOpts, + if c.ExportOpts == nil { + c.ExportOpts = make([]string, 0) } errs := make([]error, 0) - for n, ptr := range templates { + for _, str := range c.ExportOpts { var err error - *ptr, err = t.Process(*ptr, nil) + str, err = t.Process(str, nil) if err != nil { - errs = append(errs, fmt.Errorf("Error processing %s: %s", n, err)) + errs = append(errs, fmt.Errorf("Error processing %s: %s", "export_opts", err)) } } diff --git a/builder/virtualbox/common/step_export.go b/builder/virtualbox/common/step_export.go index 6967af1fe..756530572 100644 --- a/builder/virtualbox/common/step_export.go +++ b/builder/virtualbox/common/step_export.go @@ -6,7 +6,6 @@ import ( "github.com/mitchellh/packer/packer" "log" "path/filepath" - "strings" "time" ) @@ -19,7 +18,7 @@ import ( type StepExport struct { Format string OutputDir string - ExportOpts string + ExportOpts []string } func (s *StepExport) Run(state multistep.StateBag) multistep.StepAction { @@ -54,7 +53,7 @@ func (s *StepExport) Run(state multistep.StateBag) multistep.StepAction { outputPath, } - command = append(command, strings.Fields(s.ExportOpts)...) + command = append(command, s.ExportOpts...) ui.Say("Exporting virtual machine...") err := driver.VBoxManage(command...) diff --git a/website/source/docs/builders/virtualbox-iso.html.markdown b/website/source/docs/builders/virtualbox-iso.html.markdown index 2f417dca0..49a16f3e2 100644 --- a/website/source/docs/builders/virtualbox-iso.html.markdown +++ b/website/source/docs/builders/virtualbox-iso.html.markdown @@ -211,7 +211,7 @@ Optional: machine, without the file extension. By default this is "packer-BUILDNAME", where "BUILDNAME" is the name of the build. -* `export_opts` (string) - Additional options to pass to the `VBoxManage export`. +* `export_opts` (array of strings) - Additional options to pass to the `VBoxManage export`. This can be useful for passing product information to include in the resulting appliance file. diff --git a/website/source/docs/builders/virtualbox-ovf.html.markdown b/website/source/docs/builders/virtualbox-ovf.html.markdown index 47378e6c2..6bf6e49d9 100644 --- a/website/source/docs/builders/virtualbox-ovf.html.markdown +++ b/website/source/docs/builders/virtualbox-ovf.html.markdown @@ -151,7 +151,7 @@ Optional: This can be useful for passing "keepallmacs" or "keepnatmacs" options for existing ovf images. -* `export_opts` (string) - Additional options to pass to the `VBoxManage export`. +* `export_opts` (array of strings) - Additional options to pass to the `VBoxManage export`. This can be useful for passing product information to include in the resulting appliance file.