Fix up code to remove some additional steps
This commit is contained in:
parent
7c28d5590c
commit
920da9d0a4
|
@ -221,8 +221,6 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack
|
||||||
NewStepSnapshotDataDisks(azureClient, ui, &b.config),
|
NewStepSnapshotDataDisks(azureClient, ui, &b.config),
|
||||||
NewStepCaptureImage(azureClient, ui),
|
NewStepCaptureImage(azureClient, ui),
|
||||||
NewStepPublishToSharedImageGallery(azureClient, ui, &b.config),
|
NewStepPublishToSharedImageGallery(azureClient, ui, &b.config),
|
||||||
NewStepDeleteOSDisk(azureClient, ui),
|
|
||||||
NewStepDeleteAdditionalDisks(azureClient, ui),
|
|
||||||
}
|
}
|
||||||
} else if b.config.OSType == constants.Target_Windows {
|
} else if b.config.OSType == constants.Target_Windows {
|
||||||
steps = []multistep.Step{
|
steps = []multistep.Step{
|
||||||
|
@ -263,8 +261,6 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack
|
||||||
NewStepSnapshotDataDisks(azureClient, ui, &b.config),
|
NewStepSnapshotDataDisks(azureClient, ui, &b.config),
|
||||||
NewStepCaptureImage(azureClient, ui),
|
NewStepCaptureImage(azureClient, ui),
|
||||||
NewStepPublishToSharedImageGallery(azureClient, ui, &b.config),
|
NewStepPublishToSharedImageGallery(azureClient, ui, &b.config),
|
||||||
NewStepDeleteOSDisk(azureClient, ui),
|
|
||||||
NewStepDeleteAdditionalDisks(azureClient, ui),
|
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
return nil, fmt.Errorf("Builder does not support the os_type '%s'", b.config.OSType)
|
return nil, fmt.Errorf("Builder does not support the os_type '%s'", b.config.OSType)
|
||||||
|
|
|
@ -80,7 +80,9 @@ func (s *StepDeleteAdditionalDisk) Run(ctx context.Context, state multistep.Stat
|
||||||
s.say("Failed to delete the managed Additional Disk!")
|
s.say("Failed to delete the managed Additional Disk!")
|
||||||
return processStepResult(err, s.error, state)
|
return processStepResult(err, s.error, state)
|
||||||
}
|
}
|
||||||
} else {
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
u, err := url.Parse(additionaldisk)
|
u, err := url.Parse(additionaldisk)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
s.say("Failed to parse the Additional Disk's VHD URI!")
|
s.say("Failed to parse the Additional Disk's VHD URI!")
|
||||||
|
@ -100,7 +102,6 @@ func (s *StepDeleteAdditionalDisk) Run(ctx context.Context, state multistep.Stat
|
||||||
return processStepResult(err, s.error, state)
|
return processStepResult(err, s.error, state)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return multistep.ActionContinue
|
return multistep.ActionContinue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -90,7 +90,12 @@ func (s *StepDeployTemplate) Cleanup(state multistep.StateBag) {
|
||||||
deploymentOperation := deploymentOperations.Value()
|
deploymentOperation := deploymentOperations.Value()
|
||||||
// Sometimes an empty operation is added to the list by Azure
|
// Sometimes an empty operation is added to the list by Azure
|
||||||
if deploymentOperation.Properties.TargetResource == nil {
|
if deploymentOperation.Properties.TargetResource == nil {
|
||||||
deploymentOperations.Next()
|
if err := deploymentOperations.Next(); err != nil {
|
||||||
|
ui.Error(fmt.Sprintf("Error deleting resources. Please delete them manually.\n\n"+
|
||||||
|
"Name: %s\n"+
|
||||||
|
"Error: %s", resourceGroupName, err))
|
||||||
|
break
|
||||||
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,12 +169,12 @@ func (s *StepDeployTemplate) deleteTemplate(ctx context.Context, state multistep
|
||||||
|
|
||||||
func (s *StepDeployTemplate) getImageDetails(ctx context.Context, resourceGroupName string, computeName string) (string, string, error) {
|
func (s *StepDeployTemplate) getImageDetails(ctx context.Context, resourceGroupName string, computeName string) (string, string, error) {
|
||||||
//We can't depend on constants.ArmOSDiskVhd being set
|
//We can't depend on constants.ArmOSDiskVhd being set
|
||||||
var imageName string
|
var imageName, imageType string
|
||||||
var imageType string
|
|
||||||
vm, err := s.client.VirtualMachinesClient.Get(ctx, resourceGroupName, computeName, "")
|
vm, err := s.client.VirtualMachinesClient.Get(ctx, resourceGroupName, computeName, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return imageName, imageType, err
|
return imageName, imageType, err
|
||||||
} else {
|
}
|
||||||
|
|
||||||
if vm.StorageProfile.OsDisk.Vhd != nil {
|
if vm.StorageProfile.OsDisk.Vhd != nil {
|
||||||
imageType = "image"
|
imageType = "image"
|
||||||
imageName = *vm.StorageProfile.OsDisk.Vhd.URI
|
imageName = *vm.StorageProfile.OsDisk.Vhd.URI
|
||||||
|
@ -177,7 +182,7 @@ func (s *StepDeployTemplate) getImageDetails(ctx context.Context, resourceGroupN
|
||||||
imageType = "Microsoft.Compute/disks"
|
imageType = "Microsoft.Compute/disks"
|
||||||
imageName = *vm.StorageProfile.OsDisk.ManagedDisk.ID
|
imageName = *vm.StorageProfile.OsDisk.ManagedDisk.ID
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return imageType, imageName, nil
|
return imageType, imageName, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue