Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-10-23 00:20:22 -05:00
parent 662e3a5849
commit 2eff11bb21
3 changed files with 9 additions and 0 deletions

View File

@ -44,6 +44,9 @@ func main() {
json := aCluster.FormatJSON()
fmt.Println(json)
data, _ := aCluster.MarshalJSON()
fmt.Println(string(data))
text := aCluster.FormatTEXT()
fmt.Println(text)
}

View File

@ -53,6 +53,8 @@ func CreateSampleCluster(total int) *Cluster {
d.Cpus = 16
d.Memory = SetGB(256)
}
info := StorageInfo{Capacity: 64}
d.Humantest = &info
c.Droplets = append(c.Droplets, d)
}

View File

@ -14,6 +14,10 @@ func (s StorageInfo) MarshalJSON() ([]byte, error) {
})
}
func (s StorageInfo) FormatJSON() string {
return fmt.Sprintf("\"capacity\": \"%d GB\"", s.Capacity)
}
// UnmarshalJSON custom unmarshals JSON into the StorageInfo struct
func (s *StorageInfo) UnmarshalJSON(data []byte) error {
var raw map[string]string