mirror of
https://github.com/containers/podman.git
synced 2025-10-19 04:03:23 +08:00
Swap 'volume inspect' frontend to use the new backend
Signed-off-by: Matthew Heon <matthew.heon@pm.me>
This commit is contained in:
@ -1,6 +1,9 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/containers/buildah/pkg/formats"
|
||||||
"github.com/containers/libpod/cmd/podman/cliconfig"
|
"github.com/containers/libpod/cmd/podman/cliconfig"
|
||||||
"github.com/containers/libpod/pkg/adapter"
|
"github.com/containers/libpod/pkg/adapter"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
@ -53,5 +56,24 @@ func volumeInspectCmd(c *cliconfig.VolumeInspectValues) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
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
|
||||||
}
|
}
|
||||||
|
@ -5,14 +5,11 @@ package adapter
|
|||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"context"
|
"context"
|
||||||
"github.com/containers/libpod/libpod/define"
|
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"text/template"
|
"text/template"
|
||||||
|
|
||||||
"github.com/containers/libpod/cmd/podman/shared"
|
|
||||||
|
|
||||||
"github.com/containers/buildah"
|
"github.com/containers/buildah"
|
||||||
"github.com/containers/buildah/imagebuildah"
|
"github.com/containers/buildah/imagebuildah"
|
||||||
"github.com/containers/buildah/pkg/parse"
|
"github.com/containers/buildah/pkg/parse"
|
||||||
@ -20,7 +17,9 @@ import (
|
|||||||
"github.com/containers/image/types"
|
"github.com/containers/image/types"
|
||||||
"github.com/containers/libpod/cmd/podman/cliconfig"
|
"github.com/containers/libpod/cmd/podman/cliconfig"
|
||||||
"github.com/containers/libpod/cmd/podman/libpodruntime"
|
"github.com/containers/libpod/cmd/podman/libpodruntime"
|
||||||
|
"github.com/containers/libpod/cmd/podman/shared"
|
||||||
"github.com/containers/libpod/libpod"
|
"github.com/containers/libpod/libpod"
|
||||||
|
"github.com/containers/libpod/libpod/define"
|
||||||
"github.com/containers/libpod/libpod/events"
|
"github.com/containers/libpod/libpod/events"
|
||||||
"github.com/containers/libpod/libpod/image"
|
"github.com/containers/libpod/libpod/image"
|
||||||
"github.com/containers/libpod/pkg/rootless"
|
"github.com/containers/libpod/pkg/rootless"
|
||||||
@ -209,7 +208,7 @@ func (r *LocalRuntime) Push(ctx context.Context, srcName, destination, manifestM
|
|||||||
}
|
}
|
||||||
|
|
||||||
// InspectVolumes returns a slice of volumes based on an arg list or --all
|
// InspectVolumes returns a slice of volumes based on an arg list or --all
|
||||||
func (r *LocalRuntime) InspectVolumes(ctx context.Context, c *cliconfig.VolumeInspectValues) ([]*Volume, error) {
|
func (r *LocalRuntime) InspectVolumes(ctx context.Context, c *cliconfig.VolumeInspectValues) ([]*libpod.InspectVolumeData, error) {
|
||||||
var (
|
var (
|
||||||
volumes []*libpod.Volume
|
volumes []*libpod.Volume
|
||||||
err error
|
err error
|
||||||
@ -229,7 +228,17 @@ func (r *LocalRuntime) InspectVolumes(ctx context.Context, c *cliconfig.VolumeIn
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return libpodVolumeToVolume(volumes), nil
|
|
||||||
|
inspectVols := make([]*libpod.InspectVolumeData, 0, len(volumes))
|
||||||
|
for _, vol := range volumes {
|
||||||
|
inspectOut, err := vol.Inspect()
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrapf(err, "error inspecting volume %s", vol.Name())
|
||||||
|
}
|
||||||
|
inspectVols = append(inspectVols, inspectOut)
|
||||||
|
}
|
||||||
|
|
||||||
|
return inspectVols, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Volumes returns a slice of localruntime volumes
|
// Volumes returns a slice of localruntime volumes
|
||||||
|
Reference in New Issue
Block a user