aboutsummaryrefslogtreecommitdiff
path: root/test/testvol
diff options
context:
space:
mode:
authorSascha Grunert <sgrunert@redhat.com>2022-07-05 12:13:31 +0200
committerSascha Grunert <sgrunert@redhat.com>2022-07-05 12:13:33 +0200
commit49cb288df3224da71556e27d2e73e06d446c61f2 (patch)
tree7a69d9bbc60eb067f0e39d275648e10d577d5f22 /test/testvol
parent773eead54e2e0877e92d5871625a6cc32c582d30 (diff)
downloadpodman-49cb288df3224da71556e27d2e73e06d446c61f2.tar.gz
podman-49cb288df3224da71556e27d2e73e06d446c61f2.tar.bz2
podman-49cb288df3224da71556e27d2e73e06d446c61f2.zip
hack/test/utils: 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 'test/testvol')
-rw-r--r--test/testvol/main.go30
1 files changed, 15 insertions, 15 deletions
diff --git a/test/testvol/main.go b/test/testvol/main.go
index 99c6fb694..dd4ba642d 100644
--- a/test/testvol/main.go
+++ b/test/testvol/main.go
@@ -1,6 +1,7 @@
package main
import (
+ "fmt"
"io/ioutil"
"os"
"path/filepath"
@@ -8,7 +9,6 @@ import (
"time"
"github.com/docker/go-plugins-helpers/volume"
- "github.com/pkg/errors"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)
@@ -80,16 +80,16 @@ func startServer(socketPath string) error {
if config.path == "" {
path, err := ioutil.TempDir("", "test_volume_plugin")
if err != nil {
- return errors.Wrapf(err, "error getting directory for plugin")
+ return fmt.Errorf("error getting directory for plugin: %w", err)
}
config.path = path
} else {
pathStat, err := os.Stat(config.path)
if err != nil {
- return errors.Wrapf(err, "unable to access requested plugin state directory")
+ return fmt.Errorf("unable to access requested plugin state directory: %w", err)
}
if !pathStat.IsDir() {
- return errors.Errorf("cannot use %v as plugin state dir as it is not a directory", config.path)
+ return fmt.Errorf("cannot use %v as plugin state dir as it is not a directory", config.path)
}
}
@@ -98,7 +98,7 @@ func startServer(socketPath string) error {
server := volume.NewHandler(handle)
if err := server.ServeUnix(socketPath, 0); err != nil {
- return errors.Wrapf(err, "error starting server")
+ return fmt.Errorf("error starting server: %w", err)
}
return nil
}
@@ -147,7 +147,7 @@ func (d *DirDriver) Create(opts *volume.CreateRequest) error {
logrus.Infof("Hit Create() endpoint")
if _, exists := d.volumes[opts.Name]; exists {
- return errors.Errorf("volume with name %s already exists", opts.Name)
+ return fmt.Errorf("volume with name %s already exists", opts.Name)
}
newVol := new(dirVol)
@@ -161,7 +161,7 @@ func (d *DirDriver) Create(opts *volume.CreateRequest) error {
volPath := filepath.Join(d.volumesPath, opts.Name)
if err := os.Mkdir(volPath, 0755); err != nil {
- return errors.Wrapf(err, "error making volume directory")
+ return fmt.Errorf("error making volume directory: %w", err)
}
newVol.path = volPath
@@ -204,7 +204,7 @@ func (d *DirDriver) Get(req *volume.GetRequest) (*volume.GetResponse, error) {
vol, exists := d.volumes[req.Name]
if !exists {
logrus.Debugf("Did not find volume %s", req.Name)
- return nil, errors.Errorf("no volume with name %s found", req.Name)
+ return nil, fmt.Errorf("no volume with name %s found", req.Name)
}
logrus.Debugf("Found volume %s", req.Name)
@@ -228,19 +228,19 @@ func (d *DirDriver) Remove(req *volume.RemoveRequest) error {
vol, exists := d.volumes[req.Name]
if !exists {
logrus.Debugf("Did not find volume %s", req.Name)
- return errors.Errorf("no volume with name %s found", req.Name)
+ return fmt.Errorf("no volume with name %s found", req.Name)
}
logrus.Debugf("Found volume %s", req.Name)
if len(vol.mounts) > 0 {
logrus.Debugf("Cannot remove %s, is mounted", req.Name)
- return errors.Errorf("volume %s is mounted and cannot be removed", req.Name)
+ return fmt.Errorf("volume %s is mounted and cannot be removed", req.Name)
}
delete(d.volumes, req.Name)
if err := os.RemoveAll(vol.path); err != nil {
- return errors.Wrapf(err, "error removing mountpoint of volume %s", req.Name)
+ return fmt.Errorf("error removing mountpoint of volume %s: %w", req.Name, err)
}
logrus.Debugf("Removed volume %s", req.Name)
@@ -260,7 +260,7 @@ func (d *DirDriver) Path(req *volume.PathRequest) (*volume.PathResponse, error)
vol, exists := d.volumes[req.Name]
if !exists {
logrus.Debugf("Cannot locate volume %s", req.Name)
- return nil, errors.Errorf("no volume with name %s found", req.Name)
+ return nil, fmt.Errorf("no volume with name %s found", req.Name)
}
return &volume.PathResponse{
@@ -278,7 +278,7 @@ func (d *DirDriver) Mount(req *volume.MountRequest) (*volume.MountResponse, erro
vol, exists := d.volumes[req.Name]
if !exists {
logrus.Debugf("Cannot locate volume %s", req.Name)
- return nil, errors.Errorf("no volume with name %s found", req.Name)
+ return nil, fmt.Errorf("no volume with name %s found", req.Name)
}
vol.mounts[req.ID] = true
@@ -298,13 +298,13 @@ func (d *DirDriver) Unmount(req *volume.UnmountRequest) error {
vol, exists := d.volumes[req.Name]
if !exists {
logrus.Debugf("Cannot locate volume %s", req.Name)
- return errors.Errorf("no volume with name %s found", req.Name)
+ return fmt.Errorf("no volume with name %s found", req.Name)
}
mount := vol.mounts[req.ID]
if !mount {
logrus.Debugf("Volume %s is not mounted by %s", req.Name, req.ID)
- return errors.Errorf("volume %s is not mounted by %s", req.Name, req.ID)
+ return fmt.Errorf("volume %s is not mounted by %s", req.Name, req.ID)
}
delete(vol.mounts, req.ID)