aboutsummaryrefslogtreecommitdiff
path: root/libpod/volume_internal_linux.go
diff options
context:
space:
mode:
authorSascha Grunert <sgrunert@redhat.com>2022-07-05 11:42:22 +0200
committerSascha Grunert <sgrunert@redhat.com>2022-07-05 16:06:32 +0200
commit251d91699de4e9aaab53ab6fea262d4b6bdaae8e (patch)
tree1995c85a69f48bf129565ca60ea0b3d6205a04b4 /libpod/volume_internal_linux.go
parent340eeed0cb20855f1e6d2670704cfe67df3314f6 (diff)
downloadpodman-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/volume_internal_linux.go')
-rw-r--r--libpod/volume_internal_linux.go13
1 files changed, 7 insertions, 6 deletions
diff --git a/libpod/volume_internal_linux.go b/libpod/volume_internal_linux.go
index 7d7dea9d0..cfd60554d 100644
--- a/libpod/volume_internal_linux.go
+++ b/libpod/volume_internal_linux.go
@@ -4,12 +4,13 @@
package libpod
import (
+ "errors"
+ "fmt"
"os/exec"
"strings"
"github.com/containers/podman/v4/libpod/define"
pluginapi "github.com/docker/go-plugins-helpers/volume"
- "github.com/pkg/errors"
"github.com/sirupsen/logrus"
"golang.org/x/sys/unix"
)
@@ -51,7 +52,7 @@ func (v *Volume) mount() error {
// the same one for everything.
if v.UsesVolumeDriver() {
if v.plugin == nil {
- return errors.Wrapf(define.ErrMissingPlugin, "volume plugin %s (needed by volume %s) missing", v.Driver(), v.Name())
+ return fmt.Errorf("volume plugin %s (needed by volume %s) missing: %w", v.Driver(), v.Name(), define.ErrMissingPlugin)
}
req := new(pluginapi.MountRequest)
@@ -83,7 +84,7 @@ func (v *Volume) mount() error {
// TODO: might want to cache this path in the runtime?
mountPath, err := exec.LookPath("mount")
if err != nil {
- return errors.Wrapf(err, "locating 'mount' binary")
+ return fmt.Errorf("locating 'mount' binary: %w", err)
}
mountArgs := []string{}
if volOptions != "" {
@@ -103,7 +104,7 @@ func (v *Volume) mount() error {
logrus.Debugf("Running mount command: %s %s", mountPath, strings.Join(mountArgs, " "))
if output, err := mountCmd.CombinedOutput(); err != nil {
logrus.Debugf("Mount %v failed with %v", mountCmd, err)
- return errors.Errorf(string(output))
+ return errors.New(string(output))
}
logrus.Debugf("Mounted volume %s", v.Name())
@@ -148,7 +149,7 @@ func (v *Volume) unmount(force bool) error {
if v.state.MountCount == 0 {
if v.UsesVolumeDriver() {
if v.plugin == nil {
- return errors.Wrapf(define.ErrMissingPlugin, "volume plugin %s (needed by volume %s) missing", v.Driver(), v.Name())
+ return fmt.Errorf("volume plugin %s (needed by volume %s) missing: %w", v.Driver(), v.Name(), define.ErrMissingPlugin)
}
req := new(pluginapi.UnmountRequest)
@@ -168,7 +169,7 @@ func (v *Volume) unmount(force bool) error {
// Ignore EINVAL - the mount no longer exists.
return nil
}
- return errors.Wrapf(err, "unmounting volume %s", v.Name())
+ return fmt.Errorf("unmounting volume %s: %w", v.Name(), err)
}
logrus.Debugf("Unmounted volume %s", v.Name())
}