diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2020-10-14 13:07:11 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-14 13:07:11 -0400 |
commit | e3eb6fd0e4115162e10caf6ae2196fd8774657e0 (patch) | |
tree | 9c75804b98eefa34a2cc924c8ccb2b8fc9c40d01 /cmd/podman/volumes/inspect.go | |
parent | d30b4b7aa5076c3192faada7d408f039a40414eb (diff) | |
parent | eb4a746efcb9e76e29942461b97da797fd67109f (diff) | |
download | podman-e3eb6fd0e4115162e10caf6ae2196fd8774657e0.tar.gz podman-e3eb6fd0e4115162e10caf6ae2196fd8774657e0.tar.bz2 podman-e3eb6fd0e4115162e10caf6ae2196fd8774657e0.zip |
Merge pull request #7987 from jwhonce/jira/run-898-5
Restore --format table support
Diffstat (limited to 'cmd/podman/volumes/inspect.go')
-rw-r--r-- | cmd/podman/volumes/inspect.go | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/cmd/podman/volumes/inspect.go b/cmd/podman/volumes/inspect.go index ce24ac4e5..8d1350228 100644 --- a/cmd/podman/volumes/inspect.go +++ b/cmd/podman/volumes/inspect.go @@ -3,11 +3,11 @@ package volumes import ( "fmt" "os" - "strings" "text/template" - "github.com/containers/buildah/pkg/formats" + "github.com/containers/podman/v2/cmd/podman/parse" "github.com/containers/podman/v2/cmd/podman/registry" + "github.com/containers/podman/v2/cmd/podman/report" "github.com/containers/podman/v2/pkg/domain/entities" "github.com/pkg/errors" "github.com/spf13/cobra" @@ -53,26 +53,21 @@ func inspect(cmd *cobra.Command, args []string) error { if err != nil { return err } - switch inspectFormat { - case "", formats.JSONString: + + switch { + case parse.MatchesJSONFormat(inspectFormat), inspectFormat == "": jsonOut, err := json.MarshalIndent(responses, "", " ") if err != nil { return errors.Wrapf(err, "error marshalling inspect JSON") } fmt.Println(string(jsonOut)) default: - if !strings.HasSuffix(inspectFormat, "\n") { - inspectFormat += "\n" - } - format := "{{range . }}" + inspectFormat + "{{end}}" - tmpl, err := template.New("volumeInspect").Parse(format) + row := "{{range . }}" + report.NormalizeFormat(inspectFormat) + "{{end}}" + tmpl, err := template.New("volumeInspect").Parse(row) if err != nil { return err } - if err := tmpl.Execute(os.Stdout, responses); err != nil { - return err - } + return tmpl.Execute(os.Stdout, responses) } return nil - } |