Skip to content

Add validation to require serial device when vga type is set to serial - #1443

Open
kmonticolo wants to merge 3 commits into
Telmate:masterfrom
kmonticolo:feature/validate-vga-serial
Open

Add validation to require serial device when vga type is set to serial#1443
kmonticolo wants to merge 3 commits into
Telmate:masterfrom
kmonticolo:feature/validate-vga-serial

Conversation

@kmonticolo

Copy link
Copy Markdown

Add validation to ensure serial device is defined when vga type is serial.

@kmonticolo

Copy link
Copy Markdown
Author

fixes #1440

@Tinyblargon
Tinyblargon self-requested a review November 2, 2025 20:08
@Tinyblargon Tinyblargon added type/enhancement An improvement of existing functionality modifies/go Pull requests that update Go code size/L Denotes a PR that changes 100-499 lines, ignoring generated files resource/qemu Issue or PR related to Qemu resource test/needen This PR has to be tested labels Nov 28, 2025
Comment thread proxmox/resource_vm_qemu.go Outdated

func validateVGAAndSerial(d *schema.ResourceData) error {
// Get VGA configuration
vgaList := d.Get("vga").([]interface{})

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This panics when "vga" is not defined.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, fixed:

terraform plan

Planning failed. Terraform encountered an error while generating this plan.

╷
│ Error: when vga.type is set to 'serial', at least one serial device must be configured in the 'serial' block
│ 
│   with proxmox_vm_qemu.test,
│   on main.tf line 36, in resource "proxmox_vm_qemu" "test":
│   36: resource "proxmox_vm_qemu" "test" {

Comment thread proxmox/resource_vm_qemu.go Outdated
}
}

func validateVGAAndSerial(d *schema.ResourceData) error {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My advise would be to implement the logic by parsing the config defined by:

config := pveSDK.ConfigQemu{

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

modifies/go Pull requests that update Go code resource/qemu Issue or PR related to Qemu resource size/L Denotes a PR that changes 100-499 lines, ignoring generated files test/needen This PR has to be tested type/enhancement An improvement of existing functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants