summaryrefslogtreecommitdiff
path: root/cmd/podman/volumes/inspect.go
diff options
context:
space:
mode:
authorJhon Honce <jhonce@redhat.com>2020-10-09 09:13:22 -0700
committerJhon Honce <jhonce@redhat.com>2020-10-13 17:28:45 -0700
commiteb4a746efcb9e76e29942461b97da797fd67109f (patch)
tree980663ba01f79bd107980fd0c3205fe833503a41 /cmd/podman/volumes/inspect.go
parent7ad631b819d991559ba20e4728a6803a2546158f (diff)
downloadpodman-eb4a746efcb9e76e29942461b97da797fd67109f.tar.gz
podman-eb4a746efcb9e76e29942461b97da797fd67109f.tar.bz2
podman-eb4a746efcb9e76e29942461b97da797fd67109f.zip
Restore --format table support
* system df * events * fix error handling from go routine * update tests to use gomega matchers for better error messages * system info * version * volume inspect Signed-off-by: Jhon Honce <jhonce@redhat.com>
Diffstat (limited to 'cmd/podman/volumes/inspect.go')
-rw-r--r--cmd/podman/volumes/inspect.go21
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
-
}