Commit 98639429 authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

Merge pull request #1371 from alevkin/master

post-processor/vagrant: Change creating boxes for customizing metadata.json
parents 551a7747 e0c62850
......@@ -130,12 +130,15 @@ func DirToBox(dst, dir string, ui packer.Ui, level int) error {
// WriteMetadata writes the "metadata.json" file for a Vagrant box.
func WriteMetadata(dir string, contents interface{}) error {
f, err := os.Create(filepath.Join(dir, "metadata.json"))
if err != nil {
return err
}
defer f.Close()
if _, err := os.Stat(filepath.Join(dir, "metadata.json")); os.IsNotExist(err) {
f, err := os.Create(filepath.Join(dir, "metadata.json"))
if err != nil {
return err
}
defer f.Close()
enc := json.NewEncoder(f)
return enc.Encode(contents)
enc := json.NewEncoder(f)
return enc.Encode(contents)
}
return nil
}
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