0
0
mirror of https://github.com/bpg/terraform-provider-proxmox.git synced 2025-06-30 10:33:46 +00:00

fix(vm): host parameter is optional if using mapping for usb (#1338)

Signed-off-by: Karlie Meads <68717336+karliemeads@users.noreply.github.com>
This commit is contained in:
Karlie Meads 2024-05-29 21:03:03 -04:00 committed by GitHub
parent 2f87941f2b
commit 76d980683c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 5 deletions

View File

@ -1207,8 +1207,9 @@ func (r CustomUSBDevice) EncodeValues(key string, v *url.Values) error {
return fmt.Errorf("either device ID or resource mapping must be set")
}
values := []string{
fmt.Sprintf("host=%s", *(r.HostDevice)),
values := []string{}
if r.HostDevice != nil {
values = append(values, fmt.Sprintf("host=%s", *(r.HostDevice)))
}
if r.Mapping != nil {

View File

@ -979,7 +979,7 @@ func VM() *schema.Resource {
mkHostUSBDevice: {
Type: schema.TypeString,
Description: "The USB device ID for Proxmox, in form of '<MANUFACTURER>:<ID>'",
Required: true,
Optional: true,
},
mkHostUSBDeviceMapping: {
Type: schema.TypeString,
@ -3197,9 +3197,13 @@ func vmGetHostUSBDeviceObjects(d *schema.ResourceData) vms.CustomUSBDevices {
mapping, _ := block[mkHostUSBDeviceMapping].(string)
device := vms.CustomUSBDevice{
HostDevice: &host,
USB3: &usb3,
USB3: &usb3,
}
if host != "" {
device.HostDevice = &host
}
if mapping != "" {
device.Mapping = &mapping
}