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

Fix panic when encrypted images or using security type with a Shared Image Gallery source #407

Merged
merged 1 commit into from
Apr 17, 2024

Conversation

JenGoldstrich
Copy link
Contributor

@JenGoldstrich JenGoldstrich commented Apr 16, 2024

Previously we weren't instantiating the managed image object inside the template factory whenever a build used a SIG image as a source, (i.e. had a shared_image_gallery block set), this would cause a panic when setting a disk encryption set ID, and as of v2.0.5. it would also cause a similar panic when trying to set the encryption type. To verify this I went back to version 2.0.0 and also reproduced a panic when setting a disk encryption set ID with a shared_image_gallery block as the source image

To fix this I just added nullchecks and instantiate where relevant, I ran acceptance tests on this PR

Closes #406

@JenGoldstrich JenGoldstrich marked this pull request as ready for review April 16, 2024 20:21
@JenGoldstrich JenGoldstrich requested a review from a team as a code owner April 16, 2024 20:21
@JenGoldstrich JenGoldstrich changed the title Fix panic when building from Shared Image Gallery source Fix panic when encrypted images or using security type with a Shared Image Gallery source Apr 16, 2024
@@ -748,6 +748,41 @@ func TestTrustedLaunch01(t *testing.T) {
approvaltests.VerifyJSONStruct(t, deployment.Properties.Template)
}

func TestSigSourcedWithDiskEncryptionSet(t *testing.T) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These two tests panic without the changes to template_builder.go to validate the fix

Copy link
Contributor

@lbajolet-hashicorp lbajolet-hashicorp left a comment

Choose a reason for hiding this comment

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

LGTM!

@JenGoldstrich JenGoldstrich merged commit f5b4b80 into main Apr 17, 2024
12 checks passed
@JenGoldstrich JenGoldstrich deleted the sig_sourced_encryption_panic branch April 17, 2024 16:44
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.

Confidential VM builds - Packer azure plugin crash unexpected EOF
2 participants