diff options
author | Paul Holzinger <pholzing@redhat.com> | 2022-05-30 16:48:10 +0200 |
---|---|---|
committer | Paul Holzinger <pholzing@redhat.com> | 2022-05-30 18:10:28 +0200 |
commit | ec576a54917d902df0de2daa1935ca22b102a2b9 (patch) | |
tree | 262c83c92f67862c6e68564d7c8a9ead7561f0c7 /cmd/podman/volumes | |
parent | a550af260a536aeaa35e4b8810971748a6f16f5f (diff) | |
download | podman-ec576a54917d902df0de2daa1935ca22b102a2b9.tar.gz podman-ec576a54917d902df0de2daa1935ca22b102a2b9.tar.bz2 podman-ec576a54917d902df0de2daa1935ca22b102a2b9.zip |
podman volume export/import: give better error
When the volume does not exist we should output an error stating so and
not some generic one.
Fixes #14411
Signed-off-by: Paul Holzinger <pholzing@redhat.com>
Diffstat (limited to 'cmd/podman/volumes')
-rw-r--r-- | cmd/podman/volumes/export.go | 6 | ||||
-rw-r--r-- | cmd/podman/volumes/import.go | 7 |
2 files changed, 11 insertions, 2 deletions
diff --git a/cmd/podman/volumes/export.go b/cmd/podman/volumes/export.go index 5086323f9..113f79a0b 100644 --- a/cmd/podman/volumes/export.go +++ b/cmd/podman/volumes/export.go @@ -8,6 +8,7 @@ import ( "github.com/containers/podman/v4/cmd/podman/common" "github.com/containers/podman/v4/cmd/podman/registry" "github.com/containers/podman/v4/pkg/domain/entities" + "github.com/containers/podman/v4/pkg/errorhandling" "github.com/containers/podman/v4/utils" "github.com/pkg/errors" "github.com/sirupsen/logrus" @@ -58,10 +59,13 @@ func export(cmd *cobra.Command, args []string) error { return errors.New("expects output path, use --output=[path]") } inspectOpts.Type = common.VolumeType - volumeData, _, err := containerEngine.VolumeInspect(ctx, args, inspectOpts) + volumeData, errs, err := containerEngine.VolumeInspect(ctx, args, inspectOpts) if err != nil { return err } + if len(errs) > 0 { + return errorhandling.JoinErrors(errs) + } if len(volumeData) < 1 { return errors.New("no volume data found") } diff --git a/cmd/podman/volumes/import.go b/cmd/podman/volumes/import.go index 988c5536d..76a311643 100644 --- a/cmd/podman/volumes/import.go +++ b/cmd/podman/volumes/import.go @@ -8,6 +8,7 @@ import ( "github.com/containers/podman/v4/cmd/podman/parse" "github.com/containers/podman/v4/cmd/podman/registry" "github.com/containers/podman/v4/pkg/domain/entities" + "github.com/containers/podman/v4/pkg/errorhandling" "github.com/containers/podman/v4/utils" "github.com/pkg/errors" "github.com/spf13/cobra" @@ -60,10 +61,14 @@ func importVol(cmd *cobra.Command, args []string) error { } inspectOpts.Type = common.VolumeType - volumeData, _, err := containerEngine.VolumeInspect(ctx, volumes, inspectOpts) + inspectOpts.Type = common.VolumeType + volumeData, errs, err := containerEngine.VolumeInspect(ctx, volumes, inspectOpts) if err != nil { return err } + if len(errs) > 0 { + return errorhandling.JoinErrors(errs) + } if len(volumeData) < 1 { return errors.New("no volume data found") } |