Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for packer v1.7.0 #964

Merged
merged 22 commits into from
Jul 28, 2021
Merged

Support for packer v1.7.0 #964

merged 22 commits into from
Jul 28, 2021

Conversation

bwhaley
Copy link
Contributor

@bwhaley bwhaley commented Jul 28, 2021

Fixes #948.

Adds support for running packer init in Packer version >= v1.7.0. A few comments about this change:

  • This should be backwards compatible with Packer < v1.7.0.
  • All the example Packer template are converted to HCL. I've kept the JSON equivalents in the repo for now since the old format is still supported.
  • Introduces a new dependency, hashicorp/go-version. Hopefully this is low impact/low overhead.
  • It turns out that when downloading plugins, Packer will happily stomp all over itself, causing checksum problems and difficult-to-debug failure modes if multiple tests are running and using the same plugins (e.g. the hashicorp/amazon plugin) at about the same time. To mitigate this, Terratest will instruct Packer to download plugins to a temporary directory, then will clean up when finished. This behavior is the default, but users can set DisableTemporaryPluginPath to disable it if desired.
  • The empty S3 bucket tests were unreasonably slow, so I lowered the file count from 10,000 to 1,000. Hopefully that should still be a sufficient quantity to remain an effective test.

All comments & feedback welcome!

yorinasub17
yorinasub17 previously approved these changes Jul 28, 2021
Copy link
Contributor

@yorinasub17 yorinasub17 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had a few nits, but overall LGTM! You can choose to address the nits in this PR, or in a follow up PR.

Feel free to merge as is (assuming the build passes!)

modules/packer/packer.go Outdated Show resolved Hide resolved
modules/packer/packer.go Outdated Show resolved Hide resolved
modules/packer/packer.go Outdated Show resolved Hide resolved
@bwhaley
Copy link
Contributor Author

bwhaley commented Jul 28, 2021

Thanks for the review. I've incorporated the feedback. Relevant tests are passing, but I notice that TestGitRefChecks/GetCurrentRefReturnsLightTagValue is failing with:

 git_test.go:56: 
        	Error Trace:	git_test.go:56
        	Error:      	Not equal: 
        	            	expected: "v0.0.1-1-g58d3ea8"
        	            	actual  : "v0.0.1-1-g58d3ea8f"
        	            	
        	            	Diff:
        	            	--- Expected
        	            	+++ Actual
        	            	@@ -1 +1 @@
        	            	-v0.0.1-1-g58d3ea8
        	            	+v0.0.1-1-g58d3ea8f
        	Test:       	TestGitRefChecks/GetCurrentRefReturnsLightTagValue
    --- FAIL: TestGitRefChecks/GetCurrentRefReturnsLightTagValue (0.02s)

Is this a known testing error?

@yorinasub17
Copy link
Contributor

Is this a known testing error?

I don't think this is a known error given that it passed recently. I think this might be a new error caused by overlapping git commit SHA prefixes that caused it to require another character to differentiate that one?

Copy link
Contributor

@yorinasub17 yorinasub17 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updates LGTM!

@bwhaley
Copy link
Contributor Author

bwhaley commented Jul 28, 2021

Thanks! Relevant tests are passing. Will submit a new PR to fix the GetCurrentRefReturnsLightTagValue test.

Copy link
Member

@brikis98 brikis98 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ben, it looks like a few of the Packer templates were deleted... But these were used on the Terratest home page as examples: https://terratest.gruntwork.io/#test-with-terratest. If you click "Packer" and the "build.json" tab, you get an error. Could you update those examples to use the HCL files instead?

@bwhaley
Copy link
Contributor Author

bwhaley commented Jul 29, 2021

Doh, I thought I'd found all the references. Opened #966 to fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for packer init, introduced in packer 1.7 and required after packer 2.x
3 participants