summaryrefslogtreecommitdiff
path: root/pkg/api/handlers/utils
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/api/handlers/utils')
-rw-r--r--pkg/api/handlers/utils/containers.go10
-rw-r--r--pkg/api/handlers/utils/images.go10
2 files changed, 10 insertions, 10 deletions
diff --git a/pkg/api/handlers/utils/containers.go b/pkg/api/handlers/utils/containers.go
index 1795f6ce1..80f8522fd 100644
--- a/pkg/api/handlers/utils/containers.go
+++ b/pkg/api/handlers/utils/containers.go
@@ -2,6 +2,7 @@ package utils
import (
"context"
+ "errors"
"fmt"
"net/http"
"strconv"
@@ -19,7 +20,6 @@ import (
"github.com/containers/podman/v4/libpod"
"github.com/gorilla/schema"
- "github.com/pkg/errors"
)
type waitQueryDocker struct {
@@ -39,7 +39,7 @@ func WaitContainerDocker(w http.ResponseWriter, r *http.Request) {
decoder := ctx.Value(api.DecoderKey).(*schema.Decoder)
if err = decoder.Decode(&query, r.URL.Query()); err != nil {
- Error(w, http.StatusBadRequest, errors.Wrapf(err, "failed to parse parameters for %s", r.URL.String()))
+ Error(w, http.StatusBadRequest, fmt.Errorf("failed to parse parameters for %s: %w", r.URL.String(), err))
return
}
@@ -106,7 +106,7 @@ func WaitContainerLibpod(w http.ResponseWriter, r *http.Request) {
decoder := r.Context().Value(api.DecoderKey).(*schema.Decoder)
query := waitQueryLibpod{}
if err := decoder.Decode(&query, r.URL.Query()); err != nil {
- Error(w, http.StatusBadRequest, errors.Wrapf(err, "failed to parse parameters for %s", r.URL.String()))
+ Error(w, http.StatusBadRequest, fmt.Errorf("failed to parse parameters for %s: %w", r.URL.String(), err))
return
}
@@ -130,7 +130,7 @@ func WaitContainerLibpod(w http.ResponseWriter, r *http.Request) {
exitCode, err := waitFn(conditions...)
if err != nil {
- if errors.Cause(err) == define.ErrNoSuchCtr {
+ if errors.Is(err, define.ErrNoSuchCtr) {
ContainerNotFound(w, name, err)
return
}
@@ -197,7 +197,7 @@ var notRunningStates = []define.ContainerStatus{
func waitRemoved(ctrWait containerWaitFn) (int32, error) {
code, err := ctrWait(define.ContainerStateUnknown)
- if err != nil && errors.Cause(err) == define.ErrNoSuchCtr {
+ if err != nil && errors.Is(err, define.ErrNoSuchCtr) {
return code, nil
}
return code, err
diff --git a/pkg/api/handlers/utils/images.go b/pkg/api/handlers/utils/images.go
index 77f6dcf1d..357fa2990 100644
--- a/pkg/api/handlers/utils/images.go
+++ b/pkg/api/handlers/utils/images.go
@@ -1,6 +1,7 @@
package utils
import (
+ "errors"
"fmt"
"net/http"
"strings"
@@ -15,7 +16,6 @@ import (
"github.com/containers/podman/v4/pkg/util"
"github.com/containers/storage"
"github.com/docker/distribution/reference"
- "github.com/pkg/errors"
)
// NormalizeToDockerHub normalizes the specified nameOrID to Docker Hub if the
@@ -32,7 +32,7 @@ func NormalizeToDockerHub(r *http.Request, nameOrID string) (string, error) {
// 'busybox' -> 'registry.com/busybox'.
img, candidate, err := runtime.LibimageRuntime().LookupImage(nameOrID, nil)
if err != nil {
- if errors.Cause(err) != storage.ErrImageUnknown {
+ if !errors.Is(err, storage.ErrImageUnknown) {
return "", fmt.Errorf("normalizing name for compat API: %v", err)
}
// If the image could not be resolved locally, set the
@@ -73,7 +73,7 @@ func IsRegistryReference(name string) error {
if imageRef.Transport().Name() == docker.Transport.Name() {
return nil
}
- return errors.Errorf("unsupported transport %s in %q: only docker transport is supported", imageRef.Transport().Name(), name)
+ return fmt.Errorf("unsupported transport %s in %q: only docker transport is supported", imageRef.Transport().Name(), name)
}
// ParseStorageReference parses the specified image name to a
@@ -83,12 +83,12 @@ func ParseStorageReference(name string) (types.ImageReference, error) {
storagePrefix := storageTransport.Transport.Name()
imageRef, err := alltransports.ParseImageName(name)
if err == nil && imageRef.Transport().Name() != docker.Transport.Name() {
- return nil, errors.Errorf("reference %q must be a storage reference", name)
+ return nil, fmt.Errorf("reference %q must be a storage reference", name)
} else if err != nil {
origErr := err
imageRef, err = alltransports.ParseImageName(fmt.Sprintf("%s:%s", storagePrefix, name))
if err != nil {
- return nil, errors.Wrapf(origErr, "reference %q must be a storage reference", name)
+ return nil, fmt.Errorf("reference %q must be a storage reference: %w", name, origErr)
}
}
return imageRef, nil