Skip to content

Commit ee55ebd

Browse files
committed
feat(packer): support for template directories
1 parent 5428fbc commit ee55ebd

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

modules/packer/packer.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff 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{

0 commit comments

Comments
 (0)