mirror of https://github.com/hashicorp/packer
Merge pull request #945 from benlangfeld:feature/vb_output_opts (manually)
commit
850b066408
@ -0,0 +1,27 @@
|
||||
package common
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/mitchellh/packer/packer"
|
||||
)
|
||||
|
||||
type ExportOpts struct {
|
||||
ExportOpts []string `mapstructure:"export_opts"`
|
||||
}
|
||||
|
||||
func (c *ExportOpts) Prepare(t *packer.ConfigTemplate) []error {
|
||||
if c.ExportOpts == nil {
|
||||
c.ExportOpts = make([]string, 0)
|
||||
}
|
||||
|
||||
errs := make([]error, 0)
|
||||
for i, str := range c.ExportOpts {
|
||||
var err error
|
||||
c.ExportOpts[i], err = t.Process(str, nil)
|
||||
if err != nil {
|
||||
errs = append(errs, fmt.Errorf("Error processing %s: %s", "export_opts", err))
|
||||
}
|
||||
}
|
||||
|
||||
return errs
|
||||
}
|
||||
@ -0,0 +1,20 @@
|
||||
package common
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestExportOptsPrepare_BootWait(t *testing.T) {
|
||||
var c *ExportOpts
|
||||
var errs []error
|
||||
|
||||
// Good
|
||||
c = new(ExportOpts)
|
||||
c.ExportOpts = []string{
|
||||
"--options",
|
||||
}
|
||||
errs = c.Prepare(testConfigTemplate(t))
|
||||
if len(errs) > 0 {
|
||||
t.Fatalf("should not have error: %s", errs)
|
||||
}
|
||||
}
|
||||
Loading…
Reference in new issue