summaryrefslogtreecommitdiff
path: root/cmd/podman/volumes/inspect.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-10-27 17:04:44 -0400
committerGitHub <noreply@github.com>2020-10-27 17:04:44 -0400
commit7149a7cb396dd5951f9c632e79ba3c96a7797c5f (patch)
treeb3dcd6379cd01e4d9b4bd64d89fe75a092c7ec43 /cmd/podman/volumes/inspect.go
parent26c09291a3ea2b0e05d033a1ecf0441403d0d31a (diff)
parent61deec451f279cdc09b4415fe4988c2f8548e55a (diff)
downloadpodman-7149a7cb396dd5951f9c632e79ba3c96a7797c5f.tar.gz
podman-7149a7cb396dd5951f9c632e79ba3c96a7797c5f.tar.bz2
podman-7149a7cb396dd5951f9c632e79ba3c96a7797c5f.zip
Merge pull request #8102 from ashley-cui/inspect
Add pod, volume, network to inspect package
Diffstat (limited to 'cmd/podman/volumes/inspect.go')
-rw-r--r--cmd/podman/volumes/inspect.go40
1 files changed, 8 insertions, 32 deletions
diff --git a/cmd/podman/volumes/inspect.go b/cmd/podman/volumes/inspect.go
index 732a67333..c6edcf809 100644
--- a/cmd/podman/volumes/inspect.go
+++ b/cmd/podman/volumes/inspect.go
@@ -1,16 +1,11 @@
package volumes
import (
- "fmt"
- "os"
- "text/template"
-
- "github.com/containers/common/pkg/report"
+ "github.com/containers/podman/v2/cmd/podman/inspect"
"github.com/containers/podman/v2/cmd/podman/registry"
"github.com/containers/podman/v2/pkg/domain/entities"
"github.com/pkg/errors"
"github.com/spf13/cobra"
- "golang.org/x/net/context"
)
var (
@@ -21,7 +16,7 @@ var (
Use: "inspect [options] VOLUME [VOLUME...]",
Short: "Display detailed information on one or more volumes",
Long: volumeInspectDescription,
- RunE: inspect,
+ RunE: volumeInspect,
Example: `podman volume inspect myvol
podman volume inspect --all
podman volume inspect --format "{{.Driver}} {{.Scope}}" myvol`,
@@ -29,8 +24,7 @@ var (
)
var (
- inspectOpts = entities.VolumeInspectOptions{}
- inspectFormat string
+ inspectOpts *entities.InspectOptions
)
func init() {
@@ -39,34 +33,16 @@ func init() {
Command: inspectCommand,
Parent: volumeCmd,
})
+ inspectOpts = new(entities.InspectOptions)
flags := inspectCommand.Flags()
flags.BoolVarP(&inspectOpts.All, "all", "a", false, "Inspect all volumes")
- flags.StringVarP(&inspectFormat, "format", "f", "json", "Format volume output using Go template")
+ flags.StringVarP(&inspectOpts.Format, "format", "f", "json", "Format volume output using Go template")
}
-func inspect(cmd *cobra.Command, args []string) error {
+func volumeInspect(cmd *cobra.Command, args []string) error {
if (inspectOpts.All && len(args) > 0) || (!inspectOpts.All && len(args) < 1) {
return errors.New("provide one or more volume names or use --all")
}
- responses, err := registry.ContainerEngine().VolumeInspect(context.Background(), args, inspectOpts)
- if err != nil {
- return err
- }
-
- switch {
- case report.IsJSON(inspectFormat), inspectFormat == "":
- jsonOut, err := json.MarshalIndent(responses, "", " ")
- if err != nil {
- return errors.Wrapf(err, "error marshalling inspect JSON")
- }
- fmt.Println(string(jsonOut))
- default:
- row := "{{range . }}" + report.NormalizeFormat(inspectFormat) + "{{end}}"
- tmpl, err := template.New("volumeInspect").Parse(row)
- if err != nil {
- return err
- }
- return tmpl.Execute(os.Stdout, responses)
- }
- return nil
+ inspectOpts.Type = inspect.VolumeType
+ return inspect.Inspect(args, *inspectOpts)
}