diff options
Diffstat (limited to 'helpers.go')
| -rw-r--r-- | helpers.go | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -1,6 +1,9 @@ package virtbuf import "fmt" +import ( + "google.golang.org/protobuf/encoding/protojson" +) func (x *Hypervisor) SetMemoryGB(gb int) { x.Memory = int64(gb * 1024 * 1024 * 1024) @@ -10,3 +13,12 @@ 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) +} |
