Merge pull request #6352 from harijayms/buildresourcegroup

fixing infinite loop issue deleting existing resources if we have build_resource_group parameter
This commit is contained in:
Christopher Boumenot 2018-06-07 09:35:46 -07:00 committed by GitHub
commit 6ee8c14cab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 44 additions and 0 deletions

View File

@ -38,6 +38,14 @@ func TestBuilderAcc_ManagedDisk_Windows(t *testing.T) {
}) })
} }
func TestBuilderAcc_ManagedDisk_Windows_Build_Resource_Group(t *testing.T) {
builderT.Test(t, builderT.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Builder: &Builder{},
Template: testBuilderAccManagedDiskWindowsBuildResourceGroup,
})
}
func TestBuilderAcc_ManagedDisk_Windows_DeviceLogin(t *testing.T) { func TestBuilderAcc_ManagedDisk_Windows_DeviceLogin(t *testing.T) {
if os.Getenv(DeviceLoginAcceptanceTest) == "" { if os.Getenv(DeviceLoginAcceptanceTest) == "" {
t.Skip(fmt.Sprintf( t.Skip(fmt.Sprintf(
@ -126,6 +134,40 @@ const testBuilderAccManagedDiskWindows = `
}] }]
} }
` `
const testBuilderAccManagedDiskWindowsBuildResourceGroup = `
{
"variables": {
"client_id": "{{env ` + "`ARM_CLIENT_ID`" + `}}",
"client_secret": "{{env ` + "`ARM_CLIENT_SECRET`" + `}}",
"subscription_id": "{{env ` + "`ARM_SUBSCRIPTION_ID`" + `}}"
},
"builders": [{
"type": "test",
"client_id": "{{user ` + "`client_id`" + `}}",
"client_secret": "{{user ` + "`client_secret`" + `}}",
"subscription_id": "{{user ` + "`subscription_id`" + `}}",
"build_resource_group_name" : "packer-acceptance-test",
"managed_image_resource_group_name": "packer-acceptance-test",
"managed_image_name": "testBuilderAccManagedDiskWindows-{{timestamp}}",
"os_type": "Windows",
"image_publisher": "MicrosoftWindowsServer",
"image_offer": "WindowsServer",
"image_sku": "2012-R2-Datacenter",
"communicator": "winrm",
"winrm_use_ssl": "true",
"winrm_insecure": "true",
"winrm_timeout": "3m",
"winrm_username": "packer",
"async_resourcegroup_delete": "true",
"vm_size": "Standard_DS2_v2"
}]
}
`
const testBuilderAccManagedDiskWindowsDeviceLogin = ` const testBuilderAccManagedDiskWindowsDeviceLogin = `
{ {

View File

@ -82,6 +82,7 @@ func (s *StepDeleteResourceGroup) deleteDeploymentResources(ctx context.Context,
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()
continue continue
} }

View File

@ -185,6 +185,7 @@ 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()
continue continue
} }
ui.Say(fmt.Sprintf(" -> %s : '%s'", ui.Say(fmt.Sprintf(" -> %s : '%s'",