Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions builder/azure/arm/step_get_source_image_name.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@ func (s *StepGetSourceImageName) Run(ctx context.Context, state multistep.StateB
}

if image.Properties != nil &&
image.Properties.StorageProfile.Source != nil && image.Properties.StorageProfile.Source.Id != nil {
image.Properties.StorageProfile.Source != nil && image.Properties.StorageProfile.Source.VirtualMachineId != nil {

// Shared Image Galleries can be created in two different ways
// Either directly from a VM (in the builder this means not setting managed_image_name), for these types of images we set the artifact ID as the Gallery Image ID
// Or through an intermediate managed image. in which case we use that managed image as the artifact ID.

// First check if the parent Gallery Image Version source ID is a managed image, if so we use that as our source image name
parentSourceID := *image.Properties.StorageProfile.Source.Id
parentSourceID := *image.Properties.StorageProfile.Source.VirtualMachineId
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

as i mentioned in slack, this breaks HCP Packer ancestry for SIG images that are sourced from a managed image, this does not fix the user issue y'all are concerned about with the deprecation on march 15th, so I don't think we should merge this change, thanks for taking a crack at in @anshulsharma-hashicorp

isSIGSourcedFromManagedImage, _ := regexp.MatchString("/subscriptions/[^/]*/resourceGroups/[^/]*/providers/Microsoft.Compute/images/[^/]*$", parentSourceID)

if isSIGSourcedFromManagedImage {
Expand Down
6 changes: 4 additions & 2 deletions builder/azure/arm/step_get_source_image_name_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ func TestStepGetSourceImageName(t *testing.T) {
Properties: &galleryimageversions.GalleryImageVersionProperties{
StorageProfile: galleryimageversions.GalleryImageVersionStorageProfile{
Source: &galleryimageversions.GalleryArtifactVersionFullSource{
Id: &vmSourcedSigID,
Id: &vmSourcedSigID,
VirtualMachineId: &vmSourcedSigID,
},
},
},
Expand All @@ -41,7 +42,8 @@ func TestStepGetSourceImageName(t *testing.T) {
Properties: &galleryimageversions.GalleryImageVersionProperties{
StorageProfile: galleryimageversions.GalleryImageVersionStorageProfile{
Source: &galleryimageversions.GalleryArtifactVersionFullSource{
Id: &managedImageSourcedSigID,
Id: &managedImageSourcedSigID,
VirtualMachineId: &managedImageSourcedSigID,
},
},
},
Expand Down
4 changes: 2 additions & 2 deletions builder/azure/chroot/step_get_source_image_name.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ func (s *StepGetSourceImageName) Run(ctx context.Context, state multistep.StateB
return multistep.ActionContinue
}
if image.Properties != nil &&
image.Properties.StorageProfile.Source != nil && image.Properties.StorageProfile.Source.Id != nil {
id := *image.Properties.StorageProfile.Source.Id
image.Properties.StorageProfile.Source != nil && image.Properties.StorageProfile.Source.VirtualMachineId != nil {
id := *image.Properties.StorageProfile.Source.VirtualMachineId
ui.Say(fmt.Sprintf(" -> SourceImageName: '%s'", id))
s.GeneratedData.Put("SourceImageName", id)
return multistep.ActionContinue
Expand Down
3 changes: 2 additions & 1 deletion builder/azure/chroot/step_get_source_image_name_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ func TestChrootStepGetSourceImageName_SharedImage(t *testing.T) {
Properties: &galleryimageversions.GalleryImageVersionProperties{
StorageProfile: galleryimageversions.GalleryImageVersionStorageProfile{
Source: &galleryimageversions.GalleryArtifactVersionFullSource{
Id: common.StringPtr("/subscription/resource/managed/image/name/as/source"),
Id: common.StringPtr("/subscription/resource/managed/image/name/as/source"),
VirtualMachineId: common.StringPtr("/subscription/resource/managed/image/name/as/source"),
},
},
},
Expand Down