Skip to content

Commit

Permalink
fix crash when disk.file is nil (#765)
Browse files Browse the repository at this point in the history
  • Loading branch information
angelnu committed May 24, 2023
1 parent 9a82686 commit f2ee893
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions proxmox/resource_vm_qemu.go
Original file line number Diff line number Diff line change
Expand Up @@ -1672,9 +1672,11 @@ func resourceVmQemuRead(ctx context.Context, d *schema.ResourceData, meta interf
logger.Debug().Int("vmid", vmID).Msgf("[READ] Disk Processed '%v'", qemuDisk)
// ugly hack to avoid cloudinit disk to be removed since they usually are not present in resource definition
// but are created from proxmox as ide2 so threated
if ciDisk := rxCloudInitDrive.FindStringSubmatch(qemuDisk["file"].(string)); len(ciDisk) > 0 {
config.QemuDisks[id] = nil
logger.Debug().Int("vmid", vmID).Msgf("[READ] Remove cloudinit disk")
if qemuDisk["file"] != nil {
if ciDisk := rxCloudInitDrive.FindStringSubmatch(qemuDisk["file"].(string)); len(ciDisk) > 0 {
config.QemuDisks[id] = nil
logger.Debug().Int("vmid", vmID).Msgf("[READ] Remove cloudinit disk")
}
}
// cache == "none" is required for disk creation/updates but proxmox-api-go returns cache == "" or cache == nil in reads
if qemuDisk["cache"] == "" || qemuDisk["cache"] == nil {
Expand Down

0 comments on commit f2ee893

Please sign in to comment.