diff --git a/go.mod b/go.mod index c1acc77..d7fff5d 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,6 @@ require ( github.com/docker/go v1.5.1-1 github.com/opencontainers/go-digest v1.0.0 github.com/opencontainers/image-spec v1.0.2 - github.com/pkg/errors v0.9.1 github.com/sirupsen/logrus v1.8.1 github.com/spf13/cobra v1.2.1 golang.org/x/sync v0.0.0-20210220032951-036812b2e83c @@ -41,6 +40,7 @@ require ( github.com/moby/locker v1.0.1 // indirect github.com/moby/term v0.0.0-20210610120745-9d4ed1856297 // indirect github.com/morikuni/aec v1.0.0 // indirect + github.com/pkg/errors v0.9.1 // indirect github.com/prometheus/client_golang v1.11.0 // indirect github.com/prometheus/client_model v0.2.0 // indirect github.com/prometheus/common v0.30.0 // indirect diff --git a/remotes/mount.go b/remotes/mount.go index 664ffd1..b0d02bd 100644 --- a/remotes/mount.go +++ b/remotes/mount.go @@ -2,6 +2,7 @@ package remotes import ( "context" + "errors" "fmt" "io" "strings" @@ -12,7 +13,6 @@ import ( "github.com/containerd/containerd/remotes" "github.com/docker/distribution/reference" ocischemav1 "github.com/opencontainers/image-spec/specs-go/v1" - "github.com/pkg/errors" ) const ( @@ -62,7 +62,7 @@ func (h *descriptorCopier) Handle(ctx context.Context, desc *descriptorProgress) h.eventNotifier.reportProgress(retErr) }() writer, err := pushWithAnnotation(ctx, h.targetPusher, h.originalSource, desc.Descriptor) - if errors.Cause(err) == errdefs.ErrAlreadyExists { + if errors.Is(err, errdefs.ErrAlreadyExists) { desc.markDone() if strings.Contains(err.Error(), "mounted") { desc.setAction("Mounted") @@ -79,7 +79,7 @@ func (h *descriptorCopier) Handle(ctx context.Context, desc *descriptorProgress) } defer reader.Close() err = content.Copy(ctx, writer, reader, desc.Size, desc.Digest) - if errors.Cause(err) == errdefs.ErrAlreadyExists { + if errors.Is(err, errdefs.ErrAlreadyExists) { err = nil } if err == nil { @@ -204,7 +204,7 @@ func (w *manifestWalker) walk(ctx context.Context, desc ocischemav1.Descriptor, w.progress.addRoot(descProgress) } copyOrMountWorkItem, err := w.contentHandler.createCopyTask(ctx, descProgress) - if errors.Cause(err) == errdefs.ErrAlreadyExists { + if errors.Is(err, errdefs.ErrAlreadyExists) { w.eventNotifier.reportProgress(nil) return newPromise(w.scheduler, doneDependency{}) } diff --git a/remotes/pull.go b/remotes/pull.go index 47d993b..56d35bc 100644 --- a/remotes/pull.go +++ b/remotes/pull.go @@ -3,6 +3,7 @@ package remotes import ( "context" "encoding/json" + "errors" "fmt" "io/ioutil" @@ -18,7 +19,6 @@ import ( "github.com/docker/distribution/registry/client/auth" "github.com/opencontainers/go-digest" ocischemav1 "github.com/opencontainers/image-spec/specs-go/v1" - "github.com/pkg/errors" ) // Pull pulls a bundle from an OCI Image Index manifest @@ -47,7 +47,7 @@ func getIndex(ctx context.Context, ref auth.Scope, resolver remotes.Resolver) (o logger.Debug("Getting OCI Index Descriptor") resolvedRef, indexDescriptor, err := resolver.Resolve(withMutedContext(ctx), ref.String()) if err != nil { - if errors.Cause(err) == errdefs.ErrNotFound { + if errors.Is(err, errdefs.ErrNotFound) { return ocischemav1.Index{}, ocischemav1.Descriptor{}, err } return ocischemav1.Index{}, ocischemav1.Descriptor{}, fmt.Errorf("failed to resolve bundle manifest %q: %s", ref, err) diff --git a/remotes/push.go b/remotes/push.go index 77bf330..34c3ca3 100644 --- a/remotes/push.go +++ b/remotes/push.go @@ -4,6 +4,7 @@ import ( "context" "encoding/base64" "encoding/json" + "errors" "fmt" "io" "os" @@ -26,7 +27,6 @@ import ( "github.com/docker/docker/registry" "github.com/opencontainers/go-digest" ocischemav1 "github.com/opencontainers/image-spec/specs-go/v1" - "github.com/pkg/errors" ) // ManifestOption is a callback used to customize a manifest before pushing it @@ -202,20 +202,20 @@ func pushPayload(ctx context.Context, resolver remotes.Resolver, reference strin } writer, err := pusher.Push(ctx, descriptor) if err != nil { - if errors.Cause(err) == errdefs.ErrAlreadyExists { + if errors.Is(err, errdefs.ErrAlreadyExists) { return nil } return err } defer writer.Close() if _, err := writer.Write(payload); err != nil { - if errors.Cause(err) == errdefs.ErrAlreadyExists { + if errors.Is(err, errdefs.ErrAlreadyExists) { return nil } return err } err = writer.Commit(ctx, descriptor.Size, descriptor.Digest) - if errors.Cause(err) == errdefs.ErrAlreadyExists { + if errors.Is(err, errdefs.ErrAlreadyExists) { return nil } return err