Skip to content

Commit

Permalink
Fix regression in replicated_regions attribute
Browse files Browse the repository at this point in the history
When implementing the target_region attribute for the Shared Image
Gallery Destination a regression introduced with replication_regions, where an empty Disk
encryption key was being sent along with the request. Ultimately
causing the image capture to fail with an invalid DES key error.
  • Loading branch information
nywilken committed Feb 22, 2024
1 parent 367c9f7 commit 8666fcc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
12 changes: 7 additions & 5 deletions builder/azure/arm/step_publish_to_shared_image_gallery.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,13 @@ func buildAzureImageTargetRegions(regions []TargetRegion) []galleryimageversions
name := r.Name
tr := galleryimageversions.TargetRegion{Name: name}

id := r.DiskEncryptionSetId
tr.Encryption = &galleryimageversions.EncryptionImages{
OsDiskImage: &galleryimageversions.OSDiskImageEncryption{
DiskEncryptionSetId: &id,
},
if r.DiskEncryptionSetId != "" {
id := r.DiskEncryptionSetId
tr.Encryption = &galleryimageversions.EncryptionImages{
OsDiskImage: &galleryimageversions.OSDiskImageEncryption{
DiskEncryptionSetId: &id,
},
}
}
targetRegions = append(targetRegions, tr)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,10 @@ func TestPublishToSharedImageGalleryBuildAzureImageTargetRegions(t *testing.T) {
t.Errorf("expected configured region to contain same name as input %q but got %q", inputRegion.Name, tr.Name)
}

if (inputRegion.DiskEncryptionSetId == "") && (tr.Encryption != nil) {
t.Errorf("[%q]: expected configured region with no DES id to not contain encryption %q but got %v", tc.name, inputRegion.DiskEncryptionSetId, *tr.Encryption)
}

if (inputRegion.DiskEncryptionSetId != "") && (*tr.Encryption.OsDiskImage.DiskEncryptionSetId != inputRegion.DiskEncryptionSetId) {
t.Errorf("[%q]: expected configured region to contain set DES Id %q but got %q", tc.name, inputRegion.DiskEncryptionSetId, *tr.Encryption.OsDiskImage.DiskEncryptionSetId)
}
Expand Down

0 comments on commit 8666fcc

Please sign in to comment.