summaryrefslogtreecommitdiff
path: root/cmd/podmanV2/report/templates.go
diff options
context:
space:
mode:
authorJhon Honce <jhonce@redhat.com>2020-03-23 09:04:31 -0700
committerJhon Honce <jhonce@redhat.com>2020-03-24 16:06:01 -0700
commit1d7cb7cc48d06631e2bdfd0e25eeccc8e87b042f (patch)
treea9ce6c3b2e91a797cf8174d7a4e9d62eccb4d1e8 /cmd/podmanV2/report/templates.go
parent0c084d9719772a9b68d5eb67114cf5bf001958b2 (diff)
downloadpodman-1d7cb7cc48d06631e2bdfd0e25eeccc8e87b042f.tar.gz
podman-1d7cb7cc48d06631e2bdfd0e25eeccc8e87b042f.tar.bz2
podman-1d7cb7cc48d06631e2bdfd0e25eeccc8e87b042f.zip
V2 podman images/image list
* Updated entities to support flags/options * Updated bindings caused by entities changes * Removed handlers.ImageSummary in favor of entities.ImageSummary * Introduced StringSet() container object to simply error checking Signed-off-by: Jhon Honce <jhonce@redhat.com>
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 {