etopeter/kubectl-view-utilization

human readable format doesn't work for CPU.allocatable

bernadinm opened this issue · 1 comments

Describe the bug
A clear and concise description of what the bug is.

-h doesnt work for the allocatable field.

kubectl view-utilization -h -o json | jq .CPU.allocatable
"590100"
kubectl view-utilization -o json | jq .CPU.allocatable
590100

System details

  • Operating system that client is running
  • kubectl client and server version kubectl version
v0.3.3
  • view-utilization plugin version kubectl view-utilization -v
Client Version: version.Info{Major:"1", Minor:"19", GitVersion:"v1.19.0", GitCommit:"e19964183377d0ec2052d1f1fa930c4d7575bd50", GitTreeState:"clean", BuildDate:"2020-08-26T21:54:15Z", GoVersion:"go1.15", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"17+", GitVersion:"v1.17.6-1+a8884f7132317c", GitCommit:"a8884f7132317cb20416de61547de1bcc11f0756", GitTreeState:"clean", BuildDate:"2020-07-24T02:22:06Z", GoVersion:"go1.13.9", Compiler:"gc", Platform:"linux/amd64"}

Thank you for submitting this issue. Indeed there is a bug not converting CPU allocatable to human readable format. I checked other values and everything else is fine except that one.
Issue is with variable reference alloc_cpu instead of alloc_cpu_text

printf("\"allocatable\": "quotes"%s"quotes",", alloc_cpu);

I'm going to submit fix for that.