summaryrefslogtreecommitdiff
path: root/pkg/api/handlers/compat/volumes.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/api/handlers/compat/volumes.go')
-rw-r--r--pkg/api/handlers/compat/volumes.go21
1 files changed, 11 insertions, 10 deletions
diff --git a/pkg/api/handlers/compat/volumes.go b/pkg/api/handlers/compat/volumes.go
index ff0a7af02..fe6ae36aa 100644
--- a/pkg/api/handlers/compat/volumes.go
+++ b/pkg/api/handlers/compat/volumes.go
@@ -3,6 +3,8 @@ package compat
import (
"bytes"
"encoding/json"
+ "errors"
+ "fmt"
"net/http"
"net/url"
"time"
@@ -18,7 +20,6 @@ import (
docker_api_types "github.com/docker/docker/api/types"
docker_api_types_volume "github.com/docker/docker/api/types/volume"
"github.com/gorilla/schema"
- "github.com/pkg/errors"
)
func ListVolumes(w http.ResponseWriter, r *http.Request) {
@@ -27,7 +28,7 @@ func ListVolumes(w http.ResponseWriter, r *http.Request) {
filtersMap, err := util.PrepareFilters(r)
if err != nil {
utils.Error(w, http.StatusInternalServerError,
- errors.Wrapf(err, "failed to parse parameters for %s", r.URL.String()))
+ fmt.Errorf("failed to parse parameters for %s: %w", r.URL.String(), err))
return
}
@@ -36,7 +37,7 @@ func ListVolumes(w http.ResponseWriter, r *http.Request) {
for filter := range *filtersMap {
if filter == "opts" {
utils.Error(w, http.StatusInternalServerError,
- errors.Errorf("unsupported libpod filters passed to docker endpoint"))
+ fmt.Errorf("unsupported libpod filters passed to docker endpoint"))
return
}
}
@@ -86,13 +87,13 @@ func CreateVolume(w http.ResponseWriter, r *http.Request) {
query := struct{}{}
if err := decoder.Decode(&query, r.URL.Query()); err != nil {
utils.Error(w, http.StatusInternalServerError,
- errors.Wrapf(err, "failed to parse parameters for %s", r.URL.String()))
+ fmt.Errorf("failed to parse parameters for %s: %w", r.URL.String(), err))
return
}
// decode params from body
input := docker_api_types_volume.VolumeCreateBody{}
if err := json.NewDecoder(r.Body).Decode(&input); err != nil {
- utils.Error(w, http.StatusInternalServerError, errors.Wrap(err, "Decode()"))
+ utils.Error(w, http.StatusInternalServerError, fmt.Errorf("Decode(): %w", err))
return
}
@@ -103,7 +104,7 @@ func CreateVolume(w http.ResponseWriter, r *http.Request) {
if len(input.Name) != 0 {
// See if the volume exists already
existingVolume, err = runtime.GetVolume(input.Name)
- if err != nil && errors.Cause(err) != define.ErrNoSuchVolume {
+ if err != nil && !errors.Is(err, define.ErrNoSuchVolume) {
utils.InternalServerError(w, err)
return
}
@@ -219,7 +220,7 @@ func RemoveVolume(w http.ResponseWriter, r *http.Request) {
if err := decoder.Decode(&query, r.URL.Query()); err != nil {
utils.Error(w, http.StatusInternalServerError,
- errors.Wrapf(err, "failed to parse parameters for %s", r.URL.String()))
+ fmt.Errorf("failed to parse parameters for %s: %w", r.URL.String(), err))
return
}
@@ -239,7 +240,7 @@ func RemoveVolume(w http.ResponseWriter, r *http.Request) {
if err == nil {
// As above, we do not pass `force` from the query parameters here
if err := runtime.RemoveVolume(r.Context(), vol, false, query.Timeout); err != nil {
- if errors.Cause(err) == define.ErrVolumeBeingUsed {
+ if errors.Is(err, define.ErrVolumeBeingUsed) {
utils.Error(w, http.StatusConflict, err)
} else {
utils.InternalServerError(w, err)
@@ -264,14 +265,14 @@ func PruneVolumes(w http.ResponseWriter, r *http.Request) {
runtime := r.Context().Value(api.RuntimeKey).(*libpod.Runtime)
filterMap, err := util.PrepareFilters(r)
if err != nil {
- utils.Error(w, http.StatusInternalServerError, errors.Wrap(err, "Decode()"))
+ utils.Error(w, http.StatusInternalServerError, fmt.Errorf("Decode(): %w", err))
return
}
f := (url.Values)(*filterMap)
filterFuncs, err := filters.GeneratePruneVolumeFilters(f)
if err != nil {
- utils.Error(w, http.StatusInternalServerError, errors.Wrapf(err, "failed to parse filters for %s", f.Encode()))
+ utils.Error(w, http.StatusInternalServerError, fmt.Errorf("failed to parse filters for %s: %w", f.Encode(), err))
return
}