Skip to content

Commit bf09995

Browse files
committed
feat(packer): support for template directories
1 parent 770ee4a commit bf09995

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
@@ -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{

0 commit comments

Comments
 (0)