summaryrefslogtreecommitdiff
path: root/helpers.go
diff options
context:
space:
mode:
Diffstat (limited to 'helpers.go')
-rw-r--r--helpers.go19
1 files changed, 14 insertions, 5 deletions
diff --git a/helpers.go b/helpers.go
index e1a1bf9..5549358 100644
--- a/helpers.go
+++ b/helpers.go
@@ -1,8 +1,10 @@
package virtbuf
-import "fmt"
import (
- "google.golang.org/protobuf/encoding/protojson"
+ "fmt"
+
+ "google.golang.org/protobuf/encoding/protojson"
+ "google.golang.org/protobuf/encoding/prototext"
)
func (x *Hypervisor) SetMemoryGB(gb int) {
@@ -14,11 +16,18 @@ func (x *Hypervisor) GetMemoryPrintable() string {
return fmt.Sprintf("%d GB", i)
}
-
func (c *Cluster) MarshalJSON() ([]byte, error) {
- return protojson.Marshal(c)
+ return protojson.Marshal(c)
+}
+
+func (c *Cluster) FormatJSON() string {
+ return protojson.Format(c)
+}
+
+func (c *Cluster) FormatTEXT() string {
+ return prototext.Format(c)
}
func (c *Cluster) UnmarshalJSON(data []byte) error {
- return protojson.Unmarshal(data, c)
+ return protojson.Unmarshal(data, c)
}