How do I print a human readable ResourceList
Below is my function but I'd like ResourceMemory
to scale based on the number of bytes.
For example, instead of 1024Mi instead print 1Gi etc..
Maybe there an existing function in the API I can use for this??
func printResourceList(resourceList v1.ResourceList) {
for key, value := range resourceList {
switch key {
case v1.ResourceCPU:
fmt.Printf("key: %-6s value: %s \n", key.String(), value.String())
case v1.ResourceMemory:
fmt.Printf("key: %-6s value: %vMi \n", key.String(), value.Value()/(1024*1024))
default:
fmt.Printf("key: %-6s value: %s \n", key.String(), value.String())
}
}
}