Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update 'eli describe node' to print mounts in human-readable sizes #36

Merged
merged 1 commit into from
Apr 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.