command/build,validate: use new ParseTemplateFile methods

This commit is contained in:
Mitchell Hashimoto 2013-08-09 15:13:44 -07:00
parent 8507e8098d
commit 165ce3b4a8
2 changed files with 3 additions and 21 deletions

View File

@ -6,7 +6,6 @@ import (
"fmt"
cmdcommon "github.com/mitchellh/packer/common/command"
"github.com/mitchellh/packer/packer"
"io/ioutil"
"log"
"os"
"os/signal"
@ -49,15 +48,7 @@ func (c Command) Run(env packer.Environment, args []string) int {
// Read the file into a byte array so that we can parse the template
log.Printf("Reading template: %s", args[0])
tplData, err := ioutil.ReadFile(args[0])
if err != nil {
env.Ui().Error(fmt.Sprintf("Failed to read template file: %s", err))
return 1
}
// Parse the template into a machine-usable format
log.Println("Parsing template...")
tpl, err := packer.ParseTemplate(tplData)
tpl, err := packer.ParseTemplateFile(args[0])
if err != nil {
env.Ui().Error(fmt.Sprintf("Failed to parse template: %s", err))
return 1

View File

@ -5,7 +5,6 @@ import (
"fmt"
cmdcommon "github.com/mitchellh/packer/common/command"
"github.com/mitchellh/packer/packer"
"io/ioutil"
"log"
"strings"
)
@ -41,17 +40,9 @@ func (c Command) Run(env packer.Environment, args []string) int {
return 1
}
// Read the file into a byte array so that we can parse the template
log.Printf("Reading template: %s", args[0])
tplData, err := ioutil.ReadFile(args[0])
if err != nil {
env.Ui().Error(fmt.Sprintf("Failed to read template file: %s", err))
return 1
}
// Parse the template into a machine-usable format
log.Println("Parsing template...")
tpl, err := packer.ParseTemplate(tplData)
log.Printf("Reading template: %s", args[0])
tpl, err := packer.ParseTemplateFile(args[0])
if err != nil {
env.Ui().Error(fmt.Sprintf("Failed to parse template: %s", err))
return 1