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

fix: watchdog deserialization issue

This commit is contained in:
Dan Petersen 2021-02-18 22:36:08 +01:00
parent d4f59f184d
commit 8d711a7853
2 changed files with 37 additions and 1 deletions

View File

@ -1,6 +1,8 @@
## v0.4.4 ## v0.4.4
BUG FIXES:
* resource/virtual_environment_vm: Fix watchdog deserialization issue
## v0.4.3 ## v0.4.3

View File

@ -201,7 +201,7 @@ type CustomVirtualIODevices []CustomVirtualIODevice
// CustomWatchdogDevice handles QEMU watchdog device parameters. // CustomWatchdogDevice handles QEMU watchdog device parameters.
type CustomWatchdogDevice struct { type CustomWatchdogDevice struct {
Action *string `json:"action,omitempty" url:"action,omitempty"` 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. // VirtualEnvironmentVMCloneRequestBody contains the data for an virtual machine clone request.
@ -1615,3 +1615,37 @@ func (r *CustomVGADevice) UnmarshalJSON(b []byte) error {
return nil 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
}