From 6e2135f458e7256ce687190f52fbac07c28a7e09 Mon Sep 17 00:00:00 2001 From: Ben Whaley Date: Sun, 15 Aug 2021 16:17:39 -0700 Subject: [PATCH] Skip packer init for non-HCL templates --- modules/packer/packer.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/modules/packer/packer.go b/modules/packer/packer.go index dd1f418ce..58439b796 100644 --- a/modules/packer/packer.go +++ b/modules/packer/packer.go @@ -6,6 +6,7 @@ import ( "fmt" "io/ioutil" "os" + "path/filepath" "regexp" "sync" "time" @@ -214,6 +215,12 @@ func packerInit(t testing.TestingT, options *Options) error { return nil } + extension := filepath.Ext(options.Template) + if extension != ".hcl" { + options.Logger.Logf(t, "Skipping 'packer init' because it is only supported for HCL2 templates") + return nil + } + cmd := shell.Command{ Command: "packer", Args: []string{"init", options.Template},