update go mod, fix possible typecasting issues
This commit is contained in:
+9
-9
@@ -118,9 +118,9 @@ func (pve ProxmoxClient) Node(nodeName string) (*Node, error) {
|
||||
}
|
||||
|
||||
host.Name = node.Name
|
||||
host.Cores = uint64(node.CPUInfo.CPUs)
|
||||
host.Memory = uint64(node.Memory.Total)
|
||||
host.Swap = uint64(node.Swap.Total)
|
||||
host.Cores = SafeUint64(node.CPUInfo.CPUs)
|
||||
host.Memory = node.Memory.Total
|
||||
host.Swap = node.Swap.Total
|
||||
host.pvenode = node
|
||||
|
||||
return &host, err
|
||||
@@ -158,8 +158,8 @@ func (host *Node) VirtualMachine(VMID uint) (*Instance, error) {
|
||||
|
||||
instance.Name = vm.Name
|
||||
instance.Proctype = vm.VirtualMachineConfig.CPU
|
||||
instance.Cores = uint64(vm.VirtualMachineConfig.Cores)
|
||||
instance.Memory = uint64(vm.VirtualMachineConfig.Memory) * MiB
|
||||
instance.Cores = SafeUint64(vm.VirtualMachineConfig.Cores)
|
||||
instance.Memory = SafeUint64(int(vm.VirtualMachineConfig.Memory)) * MiB
|
||||
instance.Volumes = make(map[VolumeID]*Volume)
|
||||
instance.Nets = make(map[NetID]*Net)
|
||||
instance.Devices = make(map[DeviceID]*Device)
|
||||
@@ -205,9 +205,9 @@ func (host *Node) Container(VMID uint) (*Instance, error) {
|
||||
instance.Type = CT
|
||||
|
||||
instance.Name = ct.Name
|
||||
instance.Cores = uint64(ct.ContainerConfig.Cores)
|
||||
instance.Memory = uint64(ct.ContainerConfig.Memory) * MiB
|
||||
instance.Swap = uint64(ct.ContainerConfig.Swap) * MiB
|
||||
instance.Cores = SafeUint64(ct.ContainerConfig.Cores)
|
||||
instance.Memory = SafeUint64(ct.ContainerConfig.Memory) * MiB
|
||||
instance.Swap = SafeUint64(ct.ContainerConfig.Swap) * MiB
|
||||
instance.Volumes = make(map[VolumeID]*Volume)
|
||||
instance.Nets = make(map[NetID]*Net)
|
||||
|
||||
@@ -248,7 +248,7 @@ func GetVolumeInfo(host *Node, volume string) (*Volume, error) {
|
||||
if c.Volid == volumeFile {
|
||||
volumeData.Storage = volumeStorage
|
||||
volumeData.Format = c.Format
|
||||
volumeData.Size = uint64(c.Size)
|
||||
volumeData.Size = c.Size
|
||||
volumeData.File = volumeFile
|
||||
volumeData.MP = volumeObj["mp"]
|
||||
}
|
||||
|
||||
@@ -65,3 +65,11 @@ func AnyPrefixes(s string, prefixes []string) string {
|
||||
|
||||
return ""
|
||||
}
|
||||
|
||||
func SafeUint64(i int) uint64 {
|
||||
if i < 0 {
|
||||
log.Printf("Tried to cast %d to uint64", i)
|
||||
return 0
|
||||
}
|
||||
return uint64(i)
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ require (
|
||||
github.com/cloudwego/base64x v0.1.7 // indirect
|
||||
github.com/diskfs/go-diskfs v1.9.3 // indirect
|
||||
github.com/djherbis/times v1.6.0 // indirect
|
||||
github.com/elliotwutingfeng/asciiset v0.0.0-20260129054604-cfde2086bc57 // indirect
|
||||
github.com/gabriel-vasile/mimetype v1.4.13 // indirect
|
||||
github.com/gin-contrib/sse v1.1.1 // indirect
|
||||
github.com/go-playground/locales v0.14.1 // indirect
|
||||
@@ -26,11 +25,9 @@ require (
|
||||
github.com/go-playground/validator/v10 v10.30.2 // indirect
|
||||
github.com/goccy/go-json v0.10.6 // indirect
|
||||
github.com/goccy/go-yaml v1.19.2 // indirect
|
||||
github.com/google/uuid v1.6.0 // indirect
|
||||
github.com/gorilla/websocket v1.5.3 // indirect
|
||||
github.com/jinzhu/copier v0.4.0 // indirect
|
||||
github.com/json-iterator/go v1.1.12 // indirect
|
||||
github.com/klauspost/compress v1.18.5 // indirect
|
||||
github.com/klauspost/cpuid/v2 v2.3.0 // indirect
|
||||
github.com/leodido/go-urn v1.4.0 // indirect
|
||||
github.com/magefile/mage v1.17.2 // indirect
|
||||
@@ -38,7 +35,6 @@ require (
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.3.1 // indirect
|
||||
github.com/pierrec/lz4/v4 v4.1.26 // indirect
|
||||
github.com/quic-go/qpack v0.6.0 // indirect
|
||||
github.com/quic-go/quic-go v0.59.1 // indirect
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
|
||||
|
||||
Reference in New Issue
Block a user