summaryrefslogtreecommitdiff
path: root/cmd/podmanV2/report/templates.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-03-25 01:26:21 +0100
committerGitHub <noreply@github.com>2020-03-25 01:26:21 +0100
commit69b011d3ac39b985cdbd2bacfa1eaeba166bf224 (patch)
tree21791a26464b4fe55fd879b7c649ea8cd63884db /cmd/podmanV2/report/templates.go
parentb4520649af59780df494d75f50d0b5081eafff04 (diff)
parent1d7cb7cc48d06631e2bdfd0e25eeccc8e87b042f (diff)
downloadpodman-69b011d3ac39b985cdbd2bacfa1eaeba166bf224.tar.gz
podman-69b011d3ac39b985cdbd2bacfa1eaeba166bf224.tar.bz2
podman-69b011d3ac39b985cdbd2bacfa1eaeba166bf224.zip
Merge pull request #5604 from jwhonce/wip/images
V2 podman images/image list
Diffstat (limited to 'cmd/podmanV2/report/templates.go')
-rw-r--r--cmd/podmanV2/report/templates.go29
1 files changed, 19 insertions, 10 deletions
diff --git a/cmd/podmanV2/report/templates.go b/cmd/podmanV2/report/templates.go
index dc43d4f9b..f3bc06405 100644
--- a/cmd/podmanV2/report/templates.go
+++ b/cmd/podmanV2/report/templates.go
@@ -4,6 +4,7 @@ import (
"strings"
"text/template"
"time"
+ "unicode"
"github.com/docker/go-units"
)
@@ -15,7 +16,24 @@ var defaultFuncMap = template.FuncMap{
}
return s
},
- // TODO: Remove on Go 1.14 port
+ "humanDuration": func(t int64) string {
+ return units.HumanDuration(time.Since(time.Unix(t, 0))) + " ago"
+ },
+ "humanSize": func(sz int64) string {
+ s := units.HumanSizeWithPrecision(float64(sz), 3)
+ i := strings.LastIndexFunc(s, unicode.IsNumber)
+ return s[:i+1] + " " + s[i+1:]
+ },
+ "join": strings.Join,
+ "lower": strings.ToLower,
+ "rfc3339": func(t int64) string {
+ return time.Unix(t, 0).Format(time.RFC3339)
+ },
+ "replace": strings.Replace,
+ "split": strings.Split,
+ "title": strings.Title,
+ "upper": strings.ToUpper,
+ // TODO: Remove after Go 1.14 port
"slice": func(s string, i, j int) string {
if i > j || len(s) < i {
return s
@@ -25,15 +43,6 @@ var defaultFuncMap = template.FuncMap{
}
return s[i:j]
},
- "toRFC3339": func(t int64) string {
- return time.Unix(t, 0).Format(time.RFC3339)
- },
- "toHumanDuration": func(t int64) string {
- return units.HumanDuration(time.Since(time.Unix(t, 0))) + " ago"
- },
- "toHumanSize": func(sz int64) string {
- return units.HumanSize(float64(sz))
- },
}
func ReportHeader(columns ...string) []byte {