Commit fd2d8480 authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

Lots more logging everywhere

parent bc01d288
...@@ -3,6 +3,7 @@ package build ...@@ -3,6 +3,7 @@ package build
import ( import (
"github.com/mitchellh/packer/packer" "github.com/mitchellh/packer/packer"
"io/ioutil" "io/ioutil"
"log"
) )
type Command byte type Command byte
...@@ -14,6 +15,7 @@ func (Command) Run(env packer.Environment, args []string) int { ...@@ -14,6 +15,7 @@ func (Command) Run(env packer.Environment, args []string) int {
} }
// Read the file into a byte array so that we can parse the template // Read the file into a byte array so that we can parse the template
log.Printf("Reading template: %s\n", args[0])
tplData, err := ioutil.ReadFile(args[0]) tplData, err := ioutil.ReadFile(args[0])
if err != nil { if err != nil {
env.Ui().Error("Failed to read template file: %s\n", err.Error()) env.Ui().Error("Failed to read template file: %s\n", err.Error())
...@@ -21,20 +23,28 @@ func (Command) Run(env packer.Environment, args []string) int { ...@@ -21,20 +23,28 @@ func (Command) Run(env packer.Environment, args []string) int {
} }
// Parse the template into a machine-usable format // Parse the template into a machine-usable format
_, err = packer.ParseTemplate(tplData) log.Println("Parsing template...")
tpl, err := packer.ParseTemplate(tplData)
if err != nil { if err != nil {
env.Ui().Error("Failed to parse template: %s\n", err.Error()) env.Ui().Error("Failed to parse template: %s\n", err.Error())
return 1 return 1
} }
// Go through each builder and compile the builds that we care about // Go through each builder and compile the builds that we care about
//builds := make([]Build, 0, len(tpl.Builders)) buildNames := tpl.BuildNames()
//for name, rawConfig := range tpl.Builders { builds := make([]packer.Build, 0, len(buildNames))
//builder := env.Builder(name, rawConfig) for _, buildName := range buildNames {
//build := env.Build(name, builder) log.Printf("Creating build: %s\n", buildName)
//builds = append(builds, build) build, err := tpl.Build(buildName, env.Builder)
//} if err != nil {
env.Ui().Error("Failed to create build '%s': \n\n%s\n", buildName, err)
return 1
}
builds = append(builds, build)
}
env.Ui().Say("YAY!\n")
return 0 return 0
} }
......
...@@ -124,6 +124,7 @@ func (e *coreEnvironment) Cli(args []string) (result int, err error) { ...@@ -124,6 +124,7 @@ func (e *coreEnvironment) Cli(args []string) (result int, err error) {
} }
} }
log.Printf("Executing command: %s\n", args[0])
return command.Run(e, args[1:]), nil return command.Run(e, args[1:]), 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