summaryrefslogtreecommitdiff
path: root/helpers.go
blob: e1a1bf9e3f317152f175ca0b2ebfef6ce1cebb8c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package virtbuf

import "fmt"
import (
    "google.golang.org/protobuf/encoding/protojson"
)

func (x *Hypervisor) SetMemoryGB(gb int) {
	x.Memory = int64(gb * 1024 * 1024 * 1024)
}

func (x *Hypervisor) GetMemoryPrintable() string {
	i := x.Memory / (1024 * 1024 * 1024)
	return fmt.Sprintf("%d GB", i)
}


func (c *Cluster) MarshalJSON() ([]byte, error) {
    return protojson.Marshal(c)
}

func (c *Cluster) UnmarshalJSON(data []byte) error {
    return protojson.Unmarshal(data, c)
}