Commit 7fc30436 authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

command/fix: run the iso-md5 fixer

parent ab2af979
package fix
import (
"bytes"
"encoding/json"
"flag"
"fmt"
......@@ -47,6 +48,32 @@ func (c Command) Run(env packer.Environment, args []string) int {
// Close the file since we're done with that
tplF.Close()
// Run the template through the various fixers
fixers := []Fixer{Fixers["iso-md5"]}
input := templateData
for _, fixer := range fixers {
var err error
input, err = fixer.Fix(input)
if err != nil {
env.Ui().Error(fmt.Sprintf("Error fixing: %s", err))
return 1
}
}
var output bytes.Buffer
encoder := json.NewEncoder(&output)
if err := encoder.Encode(input); err != nil {
env.Ui().Error(fmt.Sprintf("Error encoding: %s", err))
return 1
}
var indented bytes.Buffer
if err := json.Indent(&indented, output.Bytes(), "", " "); err != nil {
env.Ui().Error(fmt.Sprintf("Error encoding: %s", err))
return 1
}
env.Ui().Say(indented.String())
return 0
}
......
......@@ -9,7 +9,8 @@ Usage: packer fix [options] TEMPLATE
If the template cannot be fixed due to an error, the command will exit
with a non-zero exit status. Error messages will appear on standard error.
Options:
Fixes that are run:
iso-md5 Replaces "iso_md5" in builders with newer "iso_checksum"
-verbose Output each fix to standard error
`
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