Skip to content

Commit

Permalink
feat(packer): support for template directories
Browse files Browse the repository at this point in the history
  • Loading branch information
NefixEstrada committed Sep 4, 2023
1 parent 5428fbc commit ee55ebd
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions modules/packer/packer.go
Expand Up @@ -214,10 +214,18 @@ 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
f, err := os.Stat(options.Template)
if err != nil {
return err
}

// Only check for extensions when template is a file. If it's a directory, assume it's HCL2
if !f.IsDir() {
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{
Expand Down

0 comments on commit ee55ebd

Please sign in to comment.