Move to an array of strings for a deterministic option separation

This commit is contained in:
Ben Langfeld 2014-03-14 00:12:50 -03:00
parent d1b41f2f14
commit bfd6755859
4 changed files with 10 additions and 11 deletions

View File

@ -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))
}
}

View File

@ -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...)

View File

@ -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.

View File

@ -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.