mirror of
https://github.com/containers/podman.git
synced 2025-06-23 18:59:30 +08:00
podman image mount: print pretty table
Make sure that `podman image mount` prints a pretty table unless there is only argument passed and without a custom format. Fixing a TODO item brought me to the specific code location and revealed the fart in the logic. Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
This commit is contained in:
@ -7,7 +7,6 @@ import (
|
|||||||
"github.com/containers/common/pkg/report"
|
"github.com/containers/common/pkg/report"
|
||||||
"github.com/containers/podman/v4/cmd/podman/common"
|
"github.com/containers/podman/v4/cmd/podman/common"
|
||||||
"github.com/containers/podman/v4/cmd/podman/registry"
|
"github.com/containers/podman/v4/cmd/podman/registry"
|
||||||
"github.com/containers/podman/v4/cmd/podman/utils"
|
|
||||||
"github.com/containers/podman/v4/pkg/domain/entities"
|
"github.com/containers/podman/v4/pkg/domain/entities"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
@ -71,16 +70,12 @@ func mount(cmd *cobra.Command, args []string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(args) > 0 || mountOpts.All {
|
if len(args) == 1 && mountOpts.Format == "" && !mountOpts.All {
|
||||||
var errs utils.OutputErrors
|
if len(reports) != 1 {
|
||||||
for _, r := range reports {
|
return fmt.Errorf("internal error: expected 1 report but got %d", len(reports))
|
||||||
if r.Err == nil {
|
|
||||||
fmt.Println(r.Path)
|
|
||||||
continue
|
|
||||||
}
|
}
|
||||||
errs = append(errs, r.Err)
|
fmt.Println(reports[0].Path)
|
||||||
}
|
return nil
|
||||||
return errs.PrintErrors()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch {
|
switch {
|
||||||
|
@ -398,7 +398,6 @@ type ImageUnmountOptions struct {
|
|||||||
|
|
||||||
// ImageMountReport describes the response from image mount
|
// ImageMountReport describes the response from image mount
|
||||||
type ImageMountReport struct {
|
type ImageMountReport struct {
|
||||||
Err error
|
|
||||||
Id string // nolint
|
Id string // nolint
|
||||||
Name string
|
Name string
|
||||||
Repositories []string
|
Repositories []string
|
||||||
|
@ -159,10 +159,6 @@ func (ir *ImageEngine) Mount(ctx context.Context, nameOrIDs []string, opts entit
|
|||||||
mountReports := []*entities.ImageMountReport{}
|
mountReports := []*entities.ImageMountReport{}
|
||||||
listMountsOnly := !opts.All && len(nameOrIDs) == 0
|
listMountsOnly := !opts.All && len(nameOrIDs) == 0
|
||||||
for _, i := range images {
|
for _, i := range images {
|
||||||
// TODO: the .Err fields are not used. This pre-dates the
|
|
||||||
// libimage migration but should be addressed at some point.
|
|
||||||
// A quick glimpse at cmd/podman/image/mount.go suggests that
|
|
||||||
// the errors needed to be handled there as well.
|
|
||||||
var mountPoint string
|
var mountPoint string
|
||||||
var err error
|
var err error
|
||||||
if listMountsOnly {
|
if listMountsOnly {
|
||||||
|
@ -50,6 +50,10 @@ load helpers
|
|||||||
run_podman image mount $IMAGE
|
run_podman image mount $IMAGE
|
||||||
mount_path="$output"
|
mount_path="$output"
|
||||||
|
|
||||||
|
# Make sure that `mount -a` prints a table
|
||||||
|
run_podman image mount -a
|
||||||
|
is "$output" "$IMAGE .*$mount_path"
|
||||||
|
|
||||||
test -d $mount_path
|
test -d $mount_path
|
||||||
|
|
||||||
# Image is custom-built and has a file containing the YMD tag. Check it.
|
# Image is custom-built and has a file containing the YMD tag. Check it.
|
||||||
@ -62,8 +66,8 @@ load helpers
|
|||||||
run_podman image mount
|
run_podman image mount
|
||||||
is "$output" "$IMAGE *$mount_path" "podman image mount with no args"
|
is "$output" "$IMAGE *$mount_path" "podman image mount with no args"
|
||||||
|
|
||||||
# Clean up
|
# Clean up: -f since we mounted it twice
|
||||||
run_podman image umount $IMAGE
|
run_podman image umount -f $IMAGE
|
||||||
is "$output" "$iid" "podman image umount: image ID of what was umounted"
|
is "$output" "$iid" "podman image umount: image ID of what was umounted"
|
||||||
|
|
||||||
run_podman image umount $IMAGE
|
run_podman image umount $IMAGE
|
||||||
|
Reference in New Issue
Block a user