summaryrefslogtreecommitdiff
path: root/helpers.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-10-22 04:37:28 -0500
committerJeff Carr <[email protected]>2024-10-22 04:37:28 -0500
commit104aa512600682f8221ed2c6e0e3538336a969f3 (patch)
tree43935b71cd5d1b71286f5d2fc75a85d6e0fac0ab /helpers.go
parentca0d4f423a7892f582eced971a31caab1add9c02 (diff)
add JSON export
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'helpers.go')
-rw-r--r--helpers.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/helpers.go b/helpers.go
index 4148a23..e1a1bf9 100644
--- a/helpers.go
+++ b/helpers.go
@@ -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)
+}