diff options
author | Daniel J Walsh <dwalsh@redhat.com> | 2020-10-28 13:16:42 -0400 |
---|---|---|
committer | Daniel J Walsh <dwalsh@redhat.com> | 2020-10-30 05:34:04 -0400 |
commit | 831d7fb0d7ee007fc04b1b0ff24b77c7d5635f5e (patch) | |
tree | 2888d983aea9538c421bcb2cbfce818a1904dd7a /cmd | |
parent | 228396a99dc88fc828f23d4072a46ca8de90282f (diff) | |
download | podman-831d7fb0d7ee007fc04b1b0ff24b77c7d5635f5e.tar.gz podman-831d7fb0d7ee007fc04b1b0ff24b77c7d5635f5e.tar.bz2 podman-831d7fb0d7ee007fc04b1b0ff24b77c7d5635f5e.zip |
Stop excessive wrapping of errors
Most of the builtin golang functions like os.Stat and
os.Open report errors including the file system object
path. We should not wrap these errors and put the file path
in a second time, causing stuttering of errors when they
get presented to the user.
This patch tries to cleanup a bunch of these errors.
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/podman/containers/commit.go | 2 | ||||
-rw-r--r-- | cmd/podman/containers/run.go | 2 | ||||
-rw-r--r-- | cmd/podman/containers/runlabel.go | 3 | ||||
-rw-r--r-- | cmd/podman/generate/kube.go | 2 | ||||
-rw-r--r-- | cmd/podman/images/pull.go | 3 | ||||
-rw-r--r-- | cmd/podman/images/push.go | 3 | ||||
-rw-r--r-- | cmd/podman/images/search.go | 2 | ||||
-rw-r--r-- | cmd/podman/play/kube.go | 3 |
8 files changed, 8 insertions, 12 deletions
diff --git a/cmd/podman/containers/commit.go b/cmd/podman/containers/commit.go index 1b33d221d..412dbf7a8 100644 --- a/cmd/podman/containers/commit.go +++ b/cmd/podman/containers/commit.go @@ -95,7 +95,7 @@ func commit(cmd *cobra.Command, args []string) error { } if len(iidFile) > 0 { if err = ioutil.WriteFile(iidFile, []byte(response.Id), 0644); err != nil { - return errors.Wrapf(err, "failed to write image ID to file %q", iidFile) + return errors.Wrap(err, "failed to write image ID") } } fmt.Println(response.Id) diff --git a/cmd/podman/containers/run.go b/cmd/podman/containers/run.go index 6cadbc7ec..780cd0c0d 100644 --- a/cmd/podman/containers/run.go +++ b/cmd/podman/containers/run.go @@ -108,7 +108,7 @@ func run(cmd *cobra.Command, args []string) error { if af := cliVals.Authfile; len(af) > 0 { if _, err := os.Stat(af); err != nil { - return errors.Wrapf(err, "error checking authfile path %s", af) + return err } } diff --git a/cmd/podman/containers/runlabel.go b/cmd/podman/containers/runlabel.go index b49af36ab..92581c26f 100644 --- a/cmd/podman/containers/runlabel.go +++ b/cmd/podman/containers/runlabel.go @@ -8,7 +8,6 @@ import ( "github.com/containers/image/v5/types" "github.com/containers/podman/v2/cmd/podman/registry" "github.com/containers/podman/v2/pkg/domain/entities" - "github.com/pkg/errors" "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -75,7 +74,7 @@ func runlabel(cmd *cobra.Command, args []string) error { } if runlabelOptions.Authfile != "" { if _, err := os.Stat(runlabelOptions.Authfile); err != nil { - return errors.Wrapf(err, "error getting authfile %s", runlabelOptions.Authfile) + return err } } return registry.ContainerEngine().ContainerRunlabel(context.Background(), args[0], args[1], args[2:], runlabelOptions.ContainerRunlabelOptions) diff --git a/cmd/podman/generate/kube.go b/cmd/podman/generate/kube.go index 4935fc60c..87f7501e3 100644 --- a/cmd/podman/generate/kube.go +++ b/cmd/podman/generate/kube.go @@ -55,7 +55,7 @@ func kube(cmd *cobra.Command, args []string) error { } if cmd.Flags().Changed("filename") { if _, err := os.Stat(kubeFile); err == nil { - return errors.Errorf("cannot write to %q", kubeFile) + return errors.Errorf("cannot write to %q; file exists", kubeFile) } if err := ioutil.WriteFile(kubeFile, content, 0644); err != nil { return errors.Wrapf(err, "cannot write to %q", kubeFile) diff --git a/cmd/podman/images/pull.go b/cmd/podman/images/pull.go index 35ef80f3c..ab3b0a197 100644 --- a/cmd/podman/images/pull.go +++ b/cmd/podman/images/pull.go @@ -9,7 +9,6 @@ import ( "github.com/containers/podman/v2/cmd/podman/registry" "github.com/containers/podman/v2/pkg/domain/entities" "github.com/containers/podman/v2/pkg/util" - "github.com/pkg/errors" "github.com/spf13/cobra" "github.com/spf13/pflag" ) @@ -104,7 +103,7 @@ func imagePull(cmd *cobra.Command, args []string) error { } if pullOptions.Authfile != "" { if _, err := os.Stat(pullOptions.Authfile); err != nil { - return errors.Wrapf(err, "error getting authfile %s", pullOptions.Authfile) + return err } } diff --git a/cmd/podman/images/push.go b/cmd/podman/images/push.go index 718bd4e8c..dd45a790f 100644 --- a/cmd/podman/images/push.go +++ b/cmd/podman/images/push.go @@ -8,7 +8,6 @@ import ( "github.com/containers/podman/v2/cmd/podman/registry" "github.com/containers/podman/v2/pkg/domain/entities" "github.com/containers/podman/v2/pkg/util" - "github.com/pkg/errors" "github.com/spf13/cobra" "github.com/spf13/pflag" ) @@ -110,7 +109,7 @@ func imagePush(cmd *cobra.Command, args []string) error { if pushOptions.Authfile != "" { if _, err := os.Stat(pushOptions.Authfile); err != nil { - return errors.Wrapf(err, "error getting authfile %s", pushOptions.Authfile) + return err } } diff --git a/cmd/podman/images/search.go b/cmd/podman/images/search.go index b1a1442a6..29f5558cf 100644 --- a/cmd/podman/images/search.go +++ b/cmd/podman/images/search.go @@ -116,7 +116,7 @@ func imageSearch(cmd *cobra.Command, args []string) error { if searchOptions.Authfile != "" { if _, err := os.Stat(searchOptions.Authfile); err != nil { - return errors.Wrapf(err, "error getting authfile %s", searchOptions.Authfile) + return err } } diff --git a/cmd/podman/play/kube.go b/cmd/podman/play/kube.go index 6072ea80c..feb112ad7 100644 --- a/cmd/podman/play/kube.go +++ b/cmd/podman/play/kube.go @@ -10,7 +10,6 @@ import ( "github.com/containers/podman/v2/cmd/podman/utils" "github.com/containers/podman/v2/pkg/domain/entities" "github.com/containers/podman/v2/pkg/util" - "github.com/pkg/errors" "github.com/spf13/cobra" ) @@ -75,7 +74,7 @@ func kube(cmd *cobra.Command, args []string) error { } if kubeOptions.Authfile != "" { if _, err := os.Stat(kubeOptions.Authfile); err != nil { - return errors.Wrapf(err, "error getting authfile %s", kubeOptions.Authfile) + return err } } if kubeOptions.CredentialsCLI != "" { |