File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -214,10 +214,18 @@ func packerInit(t testing.TestingT, options *Options) error {
214214 return nil
215215 }
216216
217- extension := filepath .Ext (options .Template )
218- if extension != ".hcl" {
219- options .Logger .Logf (t , "Skipping 'packer init' because it is only supported for HCL2 templates" )
220- return nil
217+ f , err := os .Stat (options .Template )
218+ if err != nil {
219+ return err
220+ }
221+
222+ // Only check for extensions when template is a file. If it's a directory, assume it's HCL2
223+ if ! f .IsDir () {
224+ extension := filepath .Ext (options .Template )
225+ if extension != ".hcl" {
226+ options .Logger .Logf (t , "Skipping 'packer init' because it is only supported for HCL2 templates" )
227+ return nil
228+ }
221229 }
222230
223231 cmd := shell.Command {
You can’t perform that action at this time.
0 commit comments