terratest icon indicating copy to clipboard operation
terratest copied to clipboard

Packer init fails on packer 1.10

Open batinicaz opened this issue 1 year ago • 0 comments

Describe the bug

Packer 1.10 has changed the output of the packer -version command: https://github.com/hashicorp/packer/pull/12569

This change means that instead of the packer -version command just returning a version number e.g. 1.9.4 it now returns something like Packer v1.10.0.

Terratest is performing a version check to see if packer init is available, it directly constructs the version of packer from this command output: https://github.com/gruntwork-io/terratest/blob/v0.46.8/modules/packer/packer.go#L189-L193

This results in the hashicorp/go-version module throwing an error when packer 1.10 is used due to the new version output:

Malformed version: Packer v1.10.0

To Reproduce Run the packer hello world test using v1.10.0: go test -v packer_hello_world_example_test.go

Example output from test on v1.10.0:

$ go test -v packer_hello_world_example_test.go
=== RUN   TestPackerHelloWorldExample
TestPackerHelloWorldExample 2023-12-16T09:04:27Z logger.go:66: Running Packer to generate a custom artifact for template ../examples/packer-hello-world-example/build.pkr.hcl
TestPackerHelloWorldExample 2023-12-16T09:04:27Z logger.go:66: Creating a temporary directory for Packer plugins
TestPackerHelloWorldExample 2023-12-16T09:04:27Z logger.go:66: Running command packer with args [-version]
TestPackerHelloWorldExample 2023-12-16T09:04:27Z logger.go:66: Packer v1.10.0
    packer.go:91: Malformed version: Packer v1.10.0
--- FAIL: TestPackerHelloWorldExample (5.47s)
FAIL
FAIL    command-line-arguments  5.813s
FAIL

Expected behavior Terratests packer init on packer v1.10.0 works as it did previously, without failing on the version number structure.

Versions

  • Terratest version: v0.46.8
  • Environment details (Ubuntu 20.04, Windows 10, etc.): MacOS 14.2

batinicaz avatar Dec 16 '23 09:12 batinicaz