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 Jan 31, 2024
1 parent 770ee4a commit bf09995
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions modules/packer/packer.go
Expand Up @@ -213,10 +213,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 bf09995

Please sign in to comment.