summaryrefslogtreecommitdiff
path: root/cmd/podman
diff options
context:
space:
mode:
authorMatthew Heon <matthew.heon@pm.me>2019-08-02 15:02:50 -0400
committerMatthew Heon <matthew.heon@pm.me>2019-08-02 15:08:30 -0400
commitcd561cfe2f3a23388a17504be8a33faa4e7ed203 (patch)
tree90a11c76025ff278629272bc3db06ef4b1b1f1c6 /cmd/podman
parent8b72a72ca2171a8545023ee45ab42de9a78ae5f4 (diff)
downloadpodman-cd561cfe2f3a23388a17504be8a33faa4e7ed203.tar.gz
podman-cd561cfe2f3a23388a17504be8a33faa4e7ed203.tar.bz2
podman-cd561cfe2f3a23388a17504be8a33faa4e7ed203.zip
Swap 'volume inspect' frontend to use the new backend
Signed-off-by: Matthew Heon <matthew.heon@pm.me>
Diffstat (limited to 'cmd/podman')
-rw-r--r--cmd/podman/volume_inspect.go24
1 files changed, 23 insertions, 1 deletions
diff --git a/cmd/podman/volume_inspect.go b/cmd/podman/volume_inspect.go
index 1ebc5ce60..94c99a58c 100644
--- a/cmd/podman/volume_inspect.go
+++ b/cmd/podman/volume_inspect.go
@@ -1,6 +1,9 @@
package main
import (
+ "fmt"
+
+ "github.com/containers/buildah/pkg/formats"
"github.com/containers/libpod/cmd/podman/cliconfig"
"github.com/containers/libpod/pkg/adapter"
"github.com/pkg/errors"
@@ -53,5 +56,24 @@ func volumeInspectCmd(c *cliconfig.VolumeInspectValues) error {
if err != nil {
return err
}
- return generateVolLsOutput(vols, volumeLsOptions{Format: c.Format})
+
+ switch c.Format {
+ case "", formats.JSONString:
+ // Normal format - JSON string
+ jsonOut, err := json.MarshalIndent(vols, "", " ")
+ if err != nil {
+ return errors.Wrapf(err, "error marshalling inspect JSON")
+ }
+ fmt.Println(string(jsonOut))
+ default:
+ // It's a Go template.
+ interfaces := make([]interface{}, len(vols))
+ for i, vol := range vols {
+ interfaces[i] = vol
+ }
+ out := formats.StdoutTemplateArray{Output: interfaces, Template: c.Format}
+ return out.Out()
+ }
+
+ return nil
}