diff options
author | Sascha Grunert <sgrunert@redhat.com> | 2022-07-05 11:42:22 +0200 |
---|---|---|
committer | Sascha Grunert <sgrunert@redhat.com> | 2022-07-05 16:06:32 +0200 |
commit | 251d91699de4e9aaab53ab6fea262d4b6bdaae8e (patch) | |
tree | 1995c85a69f48bf129565ca60ea0b3d6205a04b4 /libpod/reset.go | |
parent | 340eeed0cb20855f1e6d2670704cfe67df3314f6 (diff) | |
download | podman-251d91699de4e9aaab53ab6fea262d4b6bdaae8e.tar.gz podman-251d91699de4e9aaab53ab6fea262d4b6bdaae8e.tar.bz2 podman-251d91699de4e9aaab53ab6fea262d4b6bdaae8e.zip |
libpod: switch to golang native error wrapping
We now use the golang error wrapping format specifier `%w` instead of
the deprecated github.com/pkg/errors package.
[NO NEW TESTS NEEDED]
Signed-off-by: Sascha Grunert <sgrunert@redhat.com>
Diffstat (limited to 'libpod/reset.go')
-rw-r--r-- | libpod/reset.go | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/libpod/reset.go b/libpod/reset.go index 30eab50fb..b3ece03bf 100644 --- a/libpod/reset.go +++ b/libpod/reset.go @@ -2,6 +2,7 @@ package libpod import ( "context" + "errors" "fmt" "os" "path/filepath" @@ -13,7 +14,6 @@ import ( "github.com/containers/podman/v4/pkg/rootless" "github.com/containers/podman/v4/pkg/util" "github.com/containers/storage" - "github.com/pkg/errors" "github.com/sirupsen/logrus" ) @@ -49,7 +49,7 @@ func (r *Runtime) removeAllDirs() error { // Volume path if err := os.RemoveAll(r.config.Engine.VolumePath); err != nil { - lastErr = errors.Wrapf(err, "removing volume path") + lastErr = fmt.Errorf("removing volume path: %w", err) } // Tmpdir @@ -57,7 +57,7 @@ func (r *Runtime) removeAllDirs() error { if lastErr != nil { logrus.Errorf("Reset: %v", lastErr) } - lastErr = errors.Wrapf(err, "removing tmp dir") + lastErr = fmt.Errorf("removing tmp dir: %w", err) } // Runroot @@ -65,7 +65,7 @@ func (r *Runtime) removeAllDirs() error { if lastErr != nil { logrus.Errorf("Reset: %v", lastErr) } - lastErr = errors.Wrapf(err, "removing run root") + lastErr = fmt.Errorf("removing run root: %w", err) } // Static dir @@ -73,7 +73,7 @@ func (r *Runtime) removeAllDirs() error { if lastErr != nil { logrus.Errorf("Reset: %v", lastErr) } - lastErr = errors.Wrapf(err, "removing static dir") + lastErr = fmt.Errorf("removing static dir: %w", err) } // Graph root @@ -81,7 +81,7 @@ func (r *Runtime) removeAllDirs() error { if lastErr != nil { logrus.Errorf("Reset: %v", lastErr) } - lastErr = errors.Wrapf(err, "removing graph root") + lastErr = fmt.Errorf("removing graph root: %w", err) } return lastErr @@ -96,7 +96,7 @@ func (r *Runtime) reset(ctx context.Context) error { } for _, p := range pods { if err := r.RemovePod(ctx, p, true, true, timeout); err != nil { - if errors.Cause(err) == define.ErrNoSuchPod { + if errors.Is(err, define.ErrNoSuchPod) { continue } logrus.Errorf("Removing Pod %s: %v", p.ID(), err) @@ -111,7 +111,7 @@ func (r *Runtime) reset(ctx context.Context) error { for _, c := range ctrs { if err := r.RemoveContainer(ctx, c, true, true, timeout); err != nil { if err := r.RemoveStorageContainer(c.ID(), true); err != nil { - if errors.Cause(err) == define.ErrNoSuchCtr { + if errors.Is(err, define.ErrNoSuchCtr) { continue } logrus.Errorf("Removing container %s: %v", c.ID(), err) @@ -134,7 +134,7 @@ func (r *Runtime) reset(ctx context.Context) error { } for _, v := range volumes { if err := r.RemoveVolume(ctx, v, true, timeout); err != nil { - if errors.Cause(err) == define.ErrNoSuchVolume { + if errors.Is(err, define.ErrNoSuchVolume) { continue } logrus.Errorf("Removing volume %s: %v", v.config.Name, err) @@ -164,7 +164,7 @@ func (r *Runtime) reset(ctx context.Context) error { if prevError != nil { logrus.Error(prevError) } - prevError = errors.Errorf("failed to remove runtime graph root dir %s, since it is the same as XDG_RUNTIME_DIR", graphRoot) + prevError = fmt.Errorf("failed to remove runtime graph root dir %s, since it is the same as XDG_RUNTIME_DIR", graphRoot) } else { if err := os.RemoveAll(graphRoot); err != nil { if prevError != nil { @@ -178,7 +178,7 @@ func (r *Runtime) reset(ctx context.Context) error { if prevError != nil { logrus.Error(prevError) } - prevError = errors.Errorf("failed to remove runtime root dir %s, since it is the same as XDG_RUNTIME_DIR", runRoot) + prevError = fmt.Errorf("failed to remove runtime root dir %s, since it is the same as XDG_RUNTIME_DIR", runRoot) } else { if err := os.RemoveAll(runRoot); err != nil { if prevError != nil { @@ -199,7 +199,7 @@ func (r *Runtime) reset(ctx context.Context) error { if prevError != nil { logrus.Error(prevError) } - prevError = errors.Errorf("failed to remove runtime tmpdir %s, since it is the same as XDG_RUNTIME_DIR", tempDir) + prevError = fmt.Errorf("failed to remove runtime tmpdir %s, since it is the same as XDG_RUNTIME_DIR", tempDir) } else { if err := os.RemoveAll(tempDir); err != nil { if prevError != nil { |