Commit 946f7458 authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

command: don't use packer.Template

parent 2fb08be1
...@@ -2,10 +2,10 @@ package command ...@@ -2,10 +2,10 @@ package command
import ( import (
"fmt" "fmt"
"github.com/mitchellh/packer/packer"
"log"
"sort" "sort"
"strings" "strings"
"github.com/mitchellh/packer/template"
) )
type InspectCommand struct { type InspectCommand struct {
...@@ -13,7 +13,7 @@ type InspectCommand struct { ...@@ -13,7 +13,7 @@ type InspectCommand struct {
} }
func (c *InspectCommand) Run(args []string) int { 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()) } flags.Usage = func() { c.Ui.Say(c.Help()) }
if err := flags.Parse(args); err != nil { if err := flags.Parse(args); err != nil {
return 1 return 1
...@@ -25,9 +25,8 @@ func (c *InspectCommand) Run(args []string) int { ...@@ -25,9 +25,8 @@ func (c *InspectCommand) Run(args []string) int {
return 1 return 1
} }
// Read the file into a byte array so that we can parse the template // Parse the template
log.Printf("Reading template: %#v", args[0]) tpl, err := template.ParseFile(args[0])
tpl, err := packer.ParseTemplateFile(args[0], nil)
if err != nil { if err != nil {
c.Ui.Error(fmt.Sprintf("Failed to parse template: %s", err)) c.Ui.Error(fmt.Sprintf("Failed to parse template: %s", err))
return 1 return 1
......
...@@ -11,7 +11,7 @@ import ( ...@@ -11,7 +11,7 @@ import (
"github.com/hashicorp/atlas-go/archive" "github.com/hashicorp/atlas-go/archive"
"github.com/hashicorp/atlas-go/v1" "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. // archiveTemplateEntry is the name the template always takes within the slug.
...@@ -58,15 +58,15 @@ func (c *PushCommand) Run(args []string) int { ...@@ -58,15 +58,15 @@ func (c *PushCommand) Run(args []string) int {
"longer used. It will be removed in the next version.")) "longer used. It will be removed in the next version."))
} }
// Read the template // Parse the template
tpl, err := packer.ParseTemplateFile(args[0], nil) tpl, err := template.ParseFile(args[0])
if err != nil { if err != nil {
c.Ui.Error(fmt.Sprintf("Failed to parse template: %s", err)) c.Ui.Error(fmt.Sprintf("Failed to parse template: %s", err))
return 1 return 1
} }
// Validate some things // Validate some things
if tpl.Push.Name == "" { if tpl.Push == nil || tpl.Push.Name == "" {
c.Ui.Error(fmt.Sprintf( c.Ui.Error(fmt.Sprintf(
"The 'push' section must be specified in the template with\n" + "The 'push' section must be specified in the template with\n" +
"at least the 'name' option set.")) "at least the 'name' option set."))
...@@ -131,7 +131,7 @@ func (c *PushCommand) Run(args []string) int { ...@@ -131,7 +131,7 @@ func (c *PushCommand) Run(args []string) int {
} }
// Find the Atlas post-processors, if possible // Find the Atlas post-processors, if possible
var atlasPPs []packer.RawPostProcessorConfig var atlasPPs []*template.PostProcessor
for _, list := range tpl.PostProcessors { for _, list := range tpl.PostProcessors {
for _, pp := range list { for _, pp := range list {
if pp.Type == "atlas" { if pp.Type == "atlas" {
......
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