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 @@ -213,10 +213,18 @@ func packerInit(t testing.TestingT, options *Options) error {
213213 return nil
214214 }
215215
216- extension := filepath .Ext (options .Template )
217- if extension != ".hcl" {
218- options .Logger .Logf (t , "Skipping 'packer init' because it is only supported for HCL2 templates" )
219- return nil
216+ f , err := os .Stat (options .Template )
217+ if err != nil {
218+ return err
219+ }
220+
221+ // Only check for extensions when template is a file. If it's a directory, assume it's HCL2
222+ if ! f .IsDir () {
223+ extension := filepath .Ext (options .Template )
224+ if extension != ".hcl" {
225+ options .Logger .Logf (t , "Skipping 'packer init' because it is only supported for HCL2 templates" )
226+ return nil
227+ }
220228 }
221229
222230 cmd := shell.Command {
You can’t perform that action at this time.
0 commit comments