[PR #255] [MERGED] Overhaul qemu disks merge #345

Closed
opened 2026-02-28 00:41:50 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Telmate/proxmox-api-go/pull/255
Author: @Tinyblargon
Created: 5/2/2023
Status: Merged
Merged: 5/14/2023
Merged by: @mleone87

Base: masterHead: Overhaul-Qemu-Disks-Merge


📝 Commits (10+)

  • 339baf9 feat: add parsing of qemu disks into struct
  • a4ec1a1 feat: Add Disks parameter in ConfigQemu struct
  • 5fc83d2 feat: Map Qemu Disks to api values
  • a89a72e style: put in alphabetical order
  • 8e45a16 feat: Add serial key to disks
  • 4967e1b docs: Add TODO
  • 7f697ad test: add test for QemuDiskSerial.Validate
  • 4454dca refactor: Add enum and validate allowed values
  • 327c98a fix: typo
  • aec9e6d feat: Add enum for QemuDiskFormat and validate allowed values

📊 Changes

13 files changed (+9989 additions, -617 deletions)

View changed files

📝 proxmox/client.go (+11 -1)
proxmox/config_guest.go (+37 -0)
📝 proxmox/config_qemu.go (+795 -616)
proxmox/config_qemu_disk.go (+1030 -0)
proxmox/config_qemu_disk_ide.go (+306 -0)
proxmox/config_qemu_disk_sata.go (+318 -0)
proxmox/config_qemu_disk_scsi.go (+480 -0)
proxmox/config_qemu_disk_test.go (+838 -0)
proxmox/config_qemu_disk_virtio.go (+384 -0)
📝 proxmox/config_qemu_test.go (+5611 -0)
📝 proxmox/util.go (+25 -0)
proxmox/util_test.go (+74 -0)
test/data/test_data_qemu/type_QemuDiskSerial.go (+80 -0)

📄 Description

This is a new implementation of the disk structure discussed in #187 and deprecates the old implementation.

Code reworked:

  • Split the logic for converting between Proxmox API and our ConfigQemu data structure to its own function to improve test-ability.
  • Moved the default for ConfigQemu to its own function to improve test-ability.
  • Removed errors from functions that would always return nil.
  • Added TODOs to ConfigQemu
  • func NewConfigQemuFromApi( will no longer return the deprecated parts of type ConfigQemu

Features added:

  • Increased the CRUD logic to make it easier for projects to implement this library (func (newConfig ConfigQemu) setAdvanced).
  • Added support for all disk types:
    • cloudinit
    • cdrom
      • iso file
      • pass-through
      • none
    • virtual disk
    • disk pass-through
  • Disks from linked clones are also supported.
  • Added Validation function for disk func (storages QemuStorages) Validate()
  • Added func MoveQemuDisk to be a full implementation for disk migration, storage/disk-type change.
  • Added type ConfigQemu.Iso to keep the spirit of the old implementation. This feature feels out of place in this code and should be delegated to implementations like the Terraform provider.
  • Disk won't be updated when nothing has changed, this would previously makes an unnecessary pending change in Proxmox.
  • Add 6000 lines of test code.

Features deprecated:

  • func (config ConfigQemu) CreateVm
  • func (config ConfigQemu) UpdateConfig
  • func (c *Client) MoveQemuDisk
  • type ConfigQemu.QemuDisks
  • type ConfigQemu.QemuIso

All the deprecated functions still work and don't make use of the new disk implementation (bugs included).

Reasoning for moving the CRUD logic to this library:

  • Implementations like the Terraform provider will now require less CRUD logic.
  • This change makes more of the CRUD logic internal to the library.
  • Due to the logic being internal it makes it easier to test and make changes when bug are found.
  • Changes will have less impact due to things like input/output stayng the same.

Currently I am working on a Terraform implementation.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Telmate/proxmox-api-go/pull/255 **Author:** [@Tinyblargon](https://github.com/Tinyblargon) **Created:** 5/2/2023 **Status:** ✅ Merged **Merged:** 5/14/2023 **Merged by:** [@mleone87](https://github.com/mleone87) **Base:** `master` ← **Head:** `Overhaul-Qemu-Disks-Merge` --- ### 📝 Commits (10+) - [`339baf9`](https://github.com/Telmate/proxmox-api-go/commit/339baf9bfa15b8bceea272c2436debf1a83c3ae0) feat: add parsing of qemu disks into struct - [`a4ec1a1`](https://github.com/Telmate/proxmox-api-go/commit/a4ec1a168366171cfe2b9243c218044a7349af02) feat: Add Disks parameter in ConfigQemu struct - [`5fc83d2`](https://github.com/Telmate/proxmox-api-go/commit/5fc83d2851fd8288fa60e2247f4d839b74cd1f4a) feat: Map Qemu Disks to api values - [`a89a72e`](https://github.com/Telmate/proxmox-api-go/commit/a89a72e1db7f831e665220cea64d65a9122d093e) style: put in alphabetical order - [`8e45a16`](https://github.com/Telmate/proxmox-api-go/commit/8e45a16075ab16fcf174f025c27580917be7a30c) feat: Add serial key to disks - [`4967e1b`](https://github.com/Telmate/proxmox-api-go/commit/4967e1bb6be59685a3e23fc4bcb0bc97a6b00644) docs: Add TODO - [`7f697ad`](https://github.com/Telmate/proxmox-api-go/commit/7f697adb62c567dcd3edb15f23f7fbc697c16781) test: add test for QemuDiskSerial.Validate - [`4454dca`](https://github.com/Telmate/proxmox-api-go/commit/4454dca2ba811e2fcadcea5a1017ee6a9d3b5a34) refactor: Add enum and validate allowed values - [`327c98a`](https://github.com/Telmate/proxmox-api-go/commit/327c98ae91318d68f7a5ae750d6bca0814c9d564) fix: typo - [`aec9e6d`](https://github.com/Telmate/proxmox-api-go/commit/aec9e6d928f9435fad4e5efbc7d26d2ad0160481) feat: Add enum for QemuDiskFormat and validate allowed values ### 📊 Changes **13 files changed** (+9989 additions, -617 deletions) <details> <summary>View changed files</summary> 📝 `proxmox/client.go` (+11 -1) ➕ `proxmox/config_guest.go` (+37 -0) 📝 `proxmox/config_qemu.go` (+795 -616) ➕ `proxmox/config_qemu_disk.go` (+1030 -0) ➕ `proxmox/config_qemu_disk_ide.go` (+306 -0) ➕ `proxmox/config_qemu_disk_sata.go` (+318 -0) ➕ `proxmox/config_qemu_disk_scsi.go` (+480 -0) ➕ `proxmox/config_qemu_disk_test.go` (+838 -0) ➕ `proxmox/config_qemu_disk_virtio.go` (+384 -0) 📝 `proxmox/config_qemu_test.go` (+5611 -0) 📝 `proxmox/util.go` (+25 -0) ➕ `proxmox/util_test.go` (+74 -0) ➕ `test/data/test_data_qemu/type_QemuDiskSerial.go` (+80 -0) </details> ### 📄 Description This is a new implementation of the disk structure discussed in #187 and deprecates the old implementation. Code reworked: - Split the logic for converting between Proxmox API and our `ConfigQemu` data structure to its own function to improve test-ability. - Moved the default for `ConfigQemu` to its own function to improve test-ability. - Removed errors from functions that would always return `nil`. - Added TODOs to `ConfigQemu` - `func NewConfigQemuFromApi(` will no longer return the deprecated parts of `type ConfigQemu` Features added: - Increased the CRUD logic to make it easier for projects to implement this library (`func (newConfig ConfigQemu) setAdvanced`). - Added support for all disk types: - cloudinit - cdrom - iso file - pass-through - none - virtual disk - disk pass-through - Disks from linked clones are also supported. - Added Validation function for disk `func (storages QemuStorages) Validate()` - Added `func MoveQemuDisk` to be a full implementation for disk migration, storage/disk-type change. - Added `type ConfigQemu.Iso` to keep the spirit of the old implementation. This feature feels out of place in this code and should be delegated to implementations like the Terraform provider. - Disk won't be updated when nothing has changed, this would previously makes an unnecessary pending change in Proxmox. - Add 6000 lines of test code. Features deprecated: - `func (config ConfigQemu) CreateVm` - `func (config ConfigQemu) UpdateConfig` - `func (c *Client) MoveQemuDisk` - `type ConfigQemu.QemuDisks` - `type ConfigQemu.QemuIso` All the deprecated functions still work and don't make use of the new disk implementation (bugs included). Reasoning for moving the CRUD logic to this library: - Implementations like the Terraform provider will now require less CRUD logic. - This change makes more of the CRUD logic internal to the library. - Due to the logic being internal it makes it easier to test and make changes when bug are found. - Changes will have less impact due to things like input/output stayng the same. Currently I am working on a Terraform implementation. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-28 00:41:50 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/proxmox-api-go#345
No description provided.