Skip to content

Commit

Permalink
Update 'eli describe node' to print mounts in human-readable sizes
Browse files Browse the repository at this point in the history
Previously `eli describe node` were printing just bytes of mount
sizes. This wasn't really user friendly and "human-readable" as it
should so updated the output to print the sizes in GB, MB, etc.
  • Loading branch information
ernoaapa committed Mar 28, 2018
1 parent 8ace815 commit 47eb74b
Show file tree
Hide file tree
Showing 6 changed files with 311 additions and 2 deletions.
4 changes: 4 additions & 0 deletions pkg/printers/humanreadable.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"github.com/ernoaapa/eliot/pkg/utils"
"github.com/pkg/errors"

"github.com/c2h5oh/datasize"
"github.com/hako/durafmt"
)

Expand Down Expand Up @@ -109,6 +110,9 @@ func (p *HumanReadablePrinter) PrintNode(info *node.Info, writer io.Writer) erro
"Subtract": func(a, b uint64) uint64 {
return a - b
},
"FormatBytes": func(v uint64) string {
return datasize.ByteSize(v).HumanReadable()
},
})
t, err := t.Parse(humanreadable.NodeDetailsTemplate)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/printers/humanreadable/NodeDetailsTemplate.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Filesystems:
Filesystem Type Size Used Available Use% Mounted on
---------- ---- ---- ---- --------- ---- ----------
{{- range .Filesystems}}
{{.Filesystem}} {{.TypeName}} {{.Total}} {{Subtract .Total .Free}} {{.Available}} {{FormatPercent .Total .Free .Available}} {{.MountDir}}
{{.Filesystem}} {{.TypeName}} {{FormatBytes .Total}} {{Subtract .Total .Free | FormatBytes}} {{FormatBytes .Available}} {{FormatPercent .Total .Free .Available}} {{.MountDir}}
{{- end}}
{{- end}}
`
3 changes: 2 additions & 1 deletion vendor.conf
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,5 @@ k8s.io/kubernetes v1.9.0-alpha.2
github.com/thejerf/suture v2.0.1
github.com/ghodss/yaml v1.0.0
github.com/syndtr/gocapability db04d3cc01c8b54962a58ec7e491717d06cfcc16
github.com/hako/durafmt 987f93c94e473e74aadc826871e61ae6b3360ebb
github.com/hako/durafmt 987f93c94e473e74aadc826871e61ae6b3360ebb
github.com/c2h5oh/datasize 4eba002a5eaea69cf8d235a388fc6b65ae68d2dd
21 changes: 21 additions & 0 deletions vendor/github.com/c2h5oh/datasize/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

66 changes: 66 additions & 0 deletions vendor/github.com/c2h5oh/datasize/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

217 changes: 217 additions & 0 deletions vendor/github.com/c2h5oh/datasize/datasize.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 47eb74b

Please sign in to comment.