command: don't use packer.Template

This commit is contained in:
Mitchell Hashimoto 2015-05-26 09:38:09 -07:00
parent 2fb08be192
commit 946f745881
2 changed files with 10 additions and 11 deletions

View File

@ -2,10 +2,10 @@ package command
import (
"fmt"
"github.com/mitchellh/packer/packer"
"log"
"sort"
"strings"
"github.com/mitchellh/packer/template"
)
type InspectCommand struct {
@ -13,7 +13,7 @@ type InspectCommand struct {
}
func (c *InspectCommand) Run(args []string) int {
flags := c.Meta.FlagSet("build", FlagSetNone)
flags := c.Meta.FlagSet("inspect", FlagSetNone)
flags.Usage = func() { c.Ui.Say(c.Help()) }
if err := flags.Parse(args); err != nil {
return 1
@ -25,9 +25,8 @@ func (c *InspectCommand) Run(args []string) int {
return 1
}
// Read the file into a byte array so that we can parse the template
log.Printf("Reading template: %#v", args[0])
tpl, err := packer.ParseTemplateFile(args[0], nil)
// Parse the template
tpl, err := template.ParseFile(args[0])
if err != nil {
c.Ui.Error(fmt.Sprintf("Failed to parse template: %s", err))
return 1

View File

@ -11,7 +11,7 @@ import (
"github.com/hashicorp/atlas-go/archive"
"github.com/hashicorp/atlas-go/v1"
"github.com/mitchellh/packer/packer"
"github.com/mitchellh/packer/template"
)
// archiveTemplateEntry is the name the template always takes within the slug.
@ -58,15 +58,15 @@ func (c *PushCommand) Run(args []string) int {
"longer used. It will be removed in the next version."))
}
// Read the template
tpl, err := packer.ParseTemplateFile(args[0], nil)
// Parse the template
tpl, err := template.ParseFile(args[0])
if err != nil {
c.Ui.Error(fmt.Sprintf("Failed to parse template: %s", err))
return 1
}
// Validate some things
if tpl.Push.Name == "" {
if tpl.Push == nil || tpl.Push.Name == "" {
c.Ui.Error(fmt.Sprintf(
"The 'push' section must be specified in the template with\n" +
"at least the 'name' option set."))
@ -131,7 +131,7 @@ func (c *PushCommand) Run(args []string) int {
}
// Find the Atlas post-processors, if possible
var atlasPPs []packer.RawPostProcessorConfig
var atlasPPs []*template.PostProcessor
for _, list := range tpl.PostProcessors {
for _, pp := range list {
if pp.Type == "atlas" {