Commit 953fd27a authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

Merge pull request #1167 from rasa/1057-add-floppy-files-to-vmware-vmx-v2

builder/vmware-vmx: add floppy_files support
parents 35b51c84 83138569
package vmx
import (
"io/ioutil"
"os"
"reflect"
"testing"
)
func TestBuilderPrepare_FloppyFiles(t *testing.T) {
var b Builder
tf, err := ioutil.TempFile("", "packer")
if err != nil {
t.Fatalf("err: %s", err)
}
tf.Close()
defer os.Remove(tf.Name())
config := testConfig(t)
config["source_path"] = tf.Name()
delete(config, "floppy_files")
warns, err := b.Prepare(config)
if len(warns) > 0 {
t.Fatalf("bad: %#v", warns)
}
if err != nil {
t.Fatalf("bad err: %s", err)
}
if len(b.config.FloppyFiles) != 0 {
t.Fatalf("bad: %#v", b.config.FloppyFiles)
}
config["floppy_files"] = []string{"foo", "bar"}
b = Builder{}
warns, err = b.Prepare(config)
if len(warns) > 0 {
t.Fatalf("bad: %#v", warns)
}
if err != nil {
t.Fatalf("should not have error: %s", err)
}
expected := []string{"foo", "bar"}
if !reflect.DeepEqual(b.config.FloppyFiles, expected) {
t.Fatalf("bad: %#v", b.config.FloppyFiles)
}
}
......@@ -72,6 +72,16 @@ func NewConfig(raws ...interface{}) (*Config, []string, error) {
}
}
for i, file := range c.FloppyFiles {
var err error
c.FloppyFiles[i], err = c.tpl.Process(file, nil)
if err != nil {
errs = packer.MultiErrorAppend(errs,
fmt.Errorf("Error processing floppy_files[%d]: %s",
i, err))
}
}
if c.SourcePath == "" {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("source_path is required"))
} else {
......
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