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 { ...@@ -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. // WriteMetadata writes the "metadata.json" file for a Vagrant box.
func WriteMetadata(dir string, contents interface{}) error { func WriteMetadata(dir string, contents interface{}) error {
f, err := os.Create(filepath.Join(dir, "metadata.json")) if _, err := os.Stat(filepath.Join(dir, "metadata.json")); os.IsNotExist(err) {
if err != nil { f, err := os.Create(filepath.Join(dir, "metadata.json"))
return err if err != nil {
} return err
defer f.Close() }
defer f.Close()
enc := json.NewEncoder(f) enc := json.NewEncoder(f)
return enc.Encode(contents) 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