diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2021-02-09 14:34:12 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-09 14:34:12 -0500 |
commit | 1112f8566d78fcb251ce9f034b98036dcd085e5a (patch) | |
tree | 532acecc14693eef736c13c7ddbf92d0a870d9f7 | |
parent | a5ab59ede7578fb9867f5d5e29db6e82319f4688 (diff) | |
parent | 27c016633bc8d4f4dfc51f7b528b57e398c884b5 (diff) | |
download | podman-1112f8566d78fcb251ce9f034b98036dcd085e5a.tar.gz podman-1112f8566d78fcb251ce9f034b98036dcd085e5a.tar.bz2 podman-1112f8566d78fcb251ce9f034b98036dcd085e5a.zip |
Merge pull request #9285 from jwhonce/issues/8773-v3.0.0
Add default template functions
-rw-r--r-- | cmd/podman/containers/ps.go | 4 | ||||
-rw-r--r-- | cmd/podman/inspect/inspect.go | 12 |
2 files changed, 5 insertions, 11 deletions
diff --git a/cmd/podman/containers/ps.go b/cmd/podman/containers/ps.go index 31f44d92f..0b5bd22fc 100644 --- a/cmd/podman/containers/ps.go +++ b/cmd/podman/containers/ps.go @@ -223,7 +223,9 @@ func ps(cmd *cobra.Command, _ []string) error { ns := strings.NewReplacer(".Namespaces.", ".") format = ns.Replace(format) - tmpl, err := template.New("listContainers").Parse(format) + tmpl, err := template.New("listContainers"). + Funcs(template.FuncMap(report.DefaultFuncs)). + Parse(format) if err != nil { return err } diff --git a/cmd/podman/inspect/inspect.go b/cmd/podman/inspect/inspect.go index 76613ae71..7708fde3c 100644 --- a/cmd/podman/inspect/inspect.go +++ b/cmd/podman/inspect/inspect.go @@ -1,7 +1,6 @@ package inspect import ( - "bytes" "context" "encoding/json" // due to a bug in json-iterator it cannot be used here "fmt" @@ -246,15 +245,8 @@ func printJSON(data []interface{}) error { } func printTmpl(typ, row string, data []interface{}) error { - t, err := template.New(typ + " inspect").Funcs(map[string]interface{}{ - "json": func(v interface{}) string { - b := &bytes.Buffer{} - e := registry.JSONLibrary().NewEncoder(b) - e.SetEscapeHTML(false) - _ = e.Encode(v) - return strings.TrimSpace(b.String()) - }, - }).Parse(row) + // We cannot use c/common/reports here, too many levels of interface{} + t, err := template.New(typ + " inspect").Funcs(template.FuncMap(report.DefaultFuncs)).Parse(row) if err != nil { return err } |