summaryrefslogtreecommitdiff
path: root/helpers.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-10-22 06:19:24 -0500
committerJeff Carr <[email protected]>2024-10-22 06:19:24 -0500
commited7dd145f607edb60df43f457e7e0013f4647aba (patch)
tree5609e5bf746864852123876b564733dd5f9bda4a /helpers.go
parent104aa512600682f8221ed2c6e0e3538336a969f3 (diff)
add prototext config format
Signed-off-by: Jeff Carr <[email protected]>
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)
}