0
0
mirror of https://github.com/bpg/terraform-provider-proxmox.git synced 2025-08-22 19:38:35 +00:00

fix(vm): panic when reading VM with SPICE USB passthrough (#1438)

Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
This commit is contained in:
Pavel Boldyrev 2024-07-11 18:38:43 -04:00 committed by GitHub
parent b63c98b13f
commit fc42ac3a5e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 1 deletions

View File

@ -77,7 +77,7 @@ func (r *CustomUSBDevice) UnmarshalJSON(b []byte) error {
for _, p := range pairs {
v := strings.Split(strings.TrimSpace(p), "=")
if len(v) == 1 {
r.HostDevice = &v[1]
r.HostDevice = &v[0]
} else if len(v) == 2 {
switch v[0] {
case "host":

View File

@ -46,6 +46,13 @@ func TestCustomUSBDevice_UnmarshalJSON(t *testing.T) {
USB3: types.CustomBool(false).Pointer(),
},
},
{
name: "spice usb device",
line: `"spice"`,
want: &CustomUSBDevice{
HostDevice: ptr.Ptr("spice"),
},
},
}
for _, tt := range tests {