summaryrefslogtreecommitdiff
path: root/cmd/podman
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-12-08 15:30:31 -0500
committerGitHub <noreply@github.com>2020-12-08 15:30:31 -0500
commit7caef9c497da0c2a16caf4f15152bc543dfb6008 (patch)
tree8b14a4ebde2b3ecc5ab8ec5f5f4b13a034661b17 /cmd/podman
parent7b2e81ec268464427e4d1365cbdd9e0bc9c582f5 (diff)
parentce474788fd9bcecdb1cd6730fecd16e5d8840ae5 (diff)
downloadpodman-7caef9c497da0c2a16caf4f15152bc543dfb6008.tar.gz
podman-7caef9c497da0c2a16caf4f15152bc543dfb6008.tar.bz2
podman-7caef9c497da0c2a16caf4f15152bc543dfb6008.zip
Merge pull request #8642 from jwhonce/issues/8444
Restore json format for fields as well as whole structs
Diffstat (limited to 'cmd/podman')
-rw-r--r--cmd/podman/inspect/inspect.go11
1 files changed, 10 insertions, 1 deletions
diff --git a/cmd/podman/inspect/inspect.go b/cmd/podman/inspect/inspect.go
index 13f36ebbd..cc48b7ae4 100644
--- a/cmd/podman/inspect/inspect.go
+++ b/cmd/podman/inspect/inspect.go
@@ -1,6 +1,7 @@
package inspect
import (
+ "bytes"
"context"
"encoding/json" // due to a bug in json-iterator it cannot be used here
"fmt"
@@ -245,7 +246,15 @@ func printJSON(data []interface{}) error {
}
func printTmpl(typ, row string, data []interface{}) error {
- t, err := template.New(typ + " inspect").Parse(row)
+ 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)
if err != nil {
return err
}