diff options
author | Brent Baude <bbaude@redhat.com> | 2020-04-09 08:47:15 -0500 |
---|---|---|
committer | Brent Baude <bbaude@redhat.com> | 2020-04-13 09:15:24 -0500 |
commit | 6f650a512948a85bbb1a8830d5700a6ce9375c1d (patch) | |
tree | 8cc88145de5cf238c2c3a0475b9553d8a5965156 /cmd/podmanV2/report/templates.go | |
parent | 1593d4c052fc0795e6fe31917edcb1ecbe5ee192 (diff) | |
download | podman-6f650a512948a85bbb1a8830d5700a6ce9375c1d.tar.gz podman-6f650a512948a85bbb1a8830d5700a6ce9375c1d.tar.bz2 podman-6f650a512948a85bbb1a8830d5700a6ce9375c1d.zip |
podmanv2 history and image remove templates
remove the use of template functions images and history to allow for straight-forward user experience. instead of templates we use structs and struct methods.
Signed-off-by: Brent Baude <bbaude@redhat.com>
Diffstat (limited to 'cmd/podmanV2/report/templates.go')
-rw-r--r-- | cmd/podmanV2/report/templates.go | 73 |
1 files changed, 0 insertions, 73 deletions
diff --git a/cmd/podmanV2/report/templates.go b/cmd/podmanV2/report/templates.go deleted file mode 100644 index e46048e97..000000000 --- a/cmd/podmanV2/report/templates.go +++ /dev/null @@ -1,73 +0,0 @@ -package report - -import ( - "strings" - "text/template" - "time" - "unicode" - - "github.com/docker/go-units" -) - -var defaultFuncMap = template.FuncMap{ - "ellipsis": func(s string, length int) string { - if len(s) > length { - return s[:length-3] + "..." - } - return s - }, - "humanDuration": func(t int64) string { - return units.HumanDuration(time.Since(time.Unix(t, 0))) + " ago" - }, - "humanDurationFromTime": func(t time.Time) string { - return units.HumanDuration(time.Since(t)) + " 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 - } - if len(s) < j { - return s[i:] - } - return s[i:j] - }, -} - -func ReportHeader(columns ...string) []byte { - hdr := make([]string, len(columns)) - for i, h := range columns { - hdr[i] = strings.ToUpper(h) - } - return []byte(strings.Join(hdr, "\t") + "\n") -} - -func AppendFuncMap(funcMap template.FuncMap) template.FuncMap { - merged := PodmanTemplateFuncs() - for k, v := range funcMap { - merged[k] = v - } - return merged -} - -func PodmanTemplateFuncs() template.FuncMap { - merged := make(template.FuncMap) - for k, v := range defaultFuncMap { - merged[k] = v - } - return merged -} |