Re-added custom conflict validation for managed disks

This commit is contained in:
Brandon Tosch 2017-03-27 11:27:54 -07:00
parent 2ac79c3f62
commit eb6f36fefb
2 changed files with 22 additions and 2 deletions

View File

@ -1317,6 +1317,14 @@ func expandAzureRmVirtualMachineDataDisk(d *schema.ResourceData) ([]compute.Data
data_disk.ManagedDisk = managedDisk
}
//BEGIN: code to be removed after GH-13016 is merged
if vhdURI != "" && managedDiskID != "" {
return nil, fmt.Errorf("[ERROR] Conflict between `vhd_uri` and `managed_disk_id` (only one or the other can be used)")
}
if vhdURI != "" && managedDiskType != "" {
return nil, fmt.Errorf("[ERROR] Conflict between `vhd_uri` and `managed_disk_type` (only one or the other can be used)")
}
//END: code to be removed after GH-13016 is merged
if managedDiskID == "" && strings.EqualFold(string(data_disk.CreateOption), string(compute.Attach)) {
return nil, fmt.Errorf("[ERROR] Must specify which disk to attach")
}
@ -1434,6 +1442,14 @@ func expandAzureRmVirtualMachineOsDisk(d *schema.ResourceData) (*compute.OSDisk,
osDisk.ManagedDisk = managedDisk
}
//BEGIN: code to be removed after GH-13016 is merged
if vhdURI != "" && managedDiskID != "" {
return nil, fmt.Errorf("[ERROR] Conflict between `vhd_uri` and `managed_disk_id` (only one or the other can be used)")
}
if vhdURI != "" && managedDiskType != "" {
return nil, fmt.Errorf("[ERROR] Conflict between `vhd_uri` and `managed_disk_type` (only one or the other can be used)")
}
//END: code to be removed after GH-13016 is merged
if managedDiskID == "" && strings.EqualFold(string(osDisk.CreateOption), string(compute.Attach)) {
return nil, fmt.Errorf("[ERROR] Must specify which disk to attach")
}

View File

@ -611,7 +611,9 @@ func TestAccAzureRMVirtualMachine_osDiskTypeConflict(t *testing.T) {
Steps: []resource.TestStep{
{
Config: config,
ExpectError: regexp.MustCompile("conflicts with storage_os_disk.0.vhd_uri"),
ExpectError: regexp.MustCompile("Conflict between `vhd_uri`"),
//Use below code instead once GH-13019 has been merged
//ExpectError: regexp.MustCompile("conflicts with storage_os_disk.0.vhd_uri"),
},
},
})
@ -627,7 +629,9 @@ func TestAccAzureRMVirtualMachine_dataDiskTypeConflict(t *testing.T) {
Steps: []resource.TestStep{
{
Config: config,
ExpectError: regexp.MustCompile("conflicts with storage_data_disk.1.vhd_uri"),
ExpectError: regexp.MustCompile("Conflict between `vhd_uri`"),
//Use below code instead once GH-13019 has been merged
//ExpectError: regexp.MustCompile("conflicts with storage_data_disk.1.vhd_uri"),
},
},
})