Skip to content

Commit

Permalink
Fix Proxmox v8.0.4 panic interface {} is string, not float64
Browse files Browse the repository at this point in the history
Workaround by jm-bertheas-datailor for:

panic: interface conversion: interface {} is string, not float64
goroutine 135 [running]:
github.com/Telmate/proxmox-api-go/proxmox.NewConfigQemuFromApi

See:
Telmate/terraform-provider-proxmox#863 (comment)
  • Loading branch information
frostyfab committed Nov 17, 2023
1 parent e7cde71 commit 9d51f1e
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion proxmox/config_qemu.go
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,18 @@ func NewConfigQemuFromApi(vmr *VmRef, client *Client) (config *ConfigQemu, err e
}
memory := 0.0
if _, isSet := vmConfig["memory"]; isSet {
memory = vmConfig["memory"].(float64)
switch vmConfig["memory"].(type) {
case float64:
memory = vmConfig["memory"].(float64)
case string:
memory2, err := strconv.ParseFloat(vmConfig["memory"].(string), 64)
if err != nil {
log.Fatal(err)
return nil, err
} else {
memory = memory2
}
}
}
balloon := 0.0
if _, isSet := vmConfig["balloon"]; isSet {
Expand Down

0 comments on commit 9d51f1e

Please sign in to comment.