distribution: replace uses of errdefs package

Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
This commit is contained in:
Matthieu MOREL
2025-05-28 05:39:02 +00:00
parent 55da8ea276
commit 083ccfa486
3 changed files with 5 additions and 6 deletions

View File

@@ -91,7 +91,7 @@ func (e unsupportedMediaTypeError) Error() string {
// log at info level.
func translatePullError(err error, ref reference.Named) error {
// FIXME(thaJeztah): cleanup error and context handling in this package, as it's really messy.
if errdefs.IsContext(err) {
if errors.Is(err, context.Canceled) || errors.Is(err, context.DeadlineExceeded) {
return err
}
switch v := err.(type) {
@@ -135,7 +135,7 @@ func isNotFound(err error) bool {
// as a result of this error.
func continueOnError(err error, mirrorEndpoint bool) bool {
// FIXME(thaJeztah): cleanup error and context handling in this package, as it's really messy.
if errdefs.IsContext(err) {
if errors.Is(err, context.Canceled) || errors.Is(err, context.DeadlineExceeded) {
return false
}
switch v := err.(type) {

View File

@@ -8,7 +8,6 @@ import (
"github.com/distribution/reference"
"github.com/docker/docker/api"
"github.com/docker/docker/api/types/events"
"github.com/docker/docker/errdefs"
refstore "github.com/docker/docker/reference"
"github.com/docker/docker/registry"
"github.com/opencontainers/go-digest"
@@ -134,7 +133,7 @@ func pullEndpoints(ctx context.Context, registryService RegistryResolver, ref re
continue
}
// FIXME(thaJeztah): cleanup error and context handling in this package, as it's really messy.
if errdefs.IsContext(err) {
if errors.Is(err, context.Canceled) || errors.Is(err, context.DeadlineExceeded) {
log.G(ctx).WithError(err).Info("Not continuing with pull after error")
} else {
log.G(ctx).WithError(err).Error("Not continuing with pull after error")

View File

@@ -4,13 +4,13 @@ import (
"bufio"
"compress/gzip"
"context"
"errors"
"fmt"
"io"
"github.com/containerd/log"
"github.com/distribution/reference"
"github.com/docker/docker/api/types/events"
"github.com/docker/docker/errdefs"
"github.com/docker/docker/pkg/progress"
)
@@ -72,7 +72,7 @@ func Push(ctx context.Context, ref reference.Named, config *ImagePushConfig) err
}
// FIXME(thaJeztah): cleanup error and context handling in this package, as it's really messy.
if errdefs.IsContext(err) {
if errors.Is(err, context.Canceled) || errors.Is(err, context.DeadlineExceeded) {
log.G(ctx).WithError(err).Info("Not continuing with push after error")
} else {
log.G(ctx).WithError(err).Error("Not continuing with push after error")