diff options
| author | Jeff Carr <[email protected]> | 2024-10-22 06:19:24 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2024-10-22 06:19:24 -0500 |
| commit | ed7dd145f607edb60df43f457e7e0013f4647aba (patch) | |
| tree | 5609e5bf746864852123876b564733dd5f9bda4a /helpers.go | |
| parent | 104aa512600682f8221ed2c6e0e3538336a969f3 (diff) | |
add prototext config format
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'helpers.go')
| -rw-r--r-- | helpers.go | 19 |
1 files changed, 14 insertions, 5 deletions
@@ -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) } |
