mirror of
https://github.com/bpg/terraform-provider-proxmox.git
synced 2025-06-30 02:31:10 +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:
parent
2f87941f2b
commit
76d980683c
@ -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 {
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user