From ed7dd145f607edb60df43f457e7e0013f4647aba Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Tue, 22 Oct 2024 06:19:24 -0500 Subject: add prototext config format Signed-off-by: Jeff Carr --- helpers.go | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'helpers.go') 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) } -- cgit v1.2.3