diff --git a/CHANGELOG.md b/CHANGELOG.md index f9132bec..f87d8641 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## v0.4.4 + +BUG FIXES: + +* resource/virtual_environment_vm: Fix watchdog deserialization issue + ## v0.4.3 BUG FIXES: diff --git a/proxmox/virtual_environment_vm_types.go b/proxmox/virtual_environment_vm_types.go index 7b10b9e5..090a9b9a 100644 --- a/proxmox/virtual_environment_vm_types.go +++ b/proxmox/virtual_environment_vm_types.go @@ -201,7 +201,7 @@ type CustomVirtualIODevices []CustomVirtualIODevice // CustomWatchdogDevice handles QEMU watchdog device parameters. type CustomWatchdogDevice struct { Action *string `json:"action,omitempty" url:"action,omitempty"` - Model string `json:"model" url:"model"` + Model *string `json:"model" url:"model"` } // VirtualEnvironmentVMCloneRequestBody contains the data for an virtual machine clone request. @@ -1615,3 +1615,37 @@ func (r *CustomVGADevice) UnmarshalJSON(b []byte) error { return nil } + +// UnmarshalJSON converts a CustomWatchdogDevice string to an object. +func (r *CustomWatchdogDevice) UnmarshalJSON(b []byte) error { + var s string + + err := json.Unmarshal(b, &s) + + if err != nil { + return err + } + + if s == "" { + return nil + } + + pairs := strings.Split(s, ",") + + for _, p := range pairs { + v := strings.Split(strings.TrimSpace(p), "=") + + if len(v) == 1 { + r.Model = &v[0] + } else if len(v) == 2 { + switch v[0] { + case "action": + r.Action = &v[1] + case "model": + r.Model = &v[1] + } + } + } + + return nil +} diff --git a/proxmoxtf/version.go b/proxmoxtf/version.go index 8b318eb0..3d362940 100644 --- a/proxmoxtf/version.go +++ b/proxmoxtf/version.go @@ -9,5 +9,5 @@ const ( TerraformProviderName = "terraform-provider-proxmox" // TerraformProviderVersion specifies the version number. - TerraformProviderVersion = "0.4.3" + TerraformProviderVersion = "0.4.4" )