Skip to content

Commit

Permalink
Merge pull request #124 from VinozzZ/remove-errors-pkg
Browse files Browse the repository at this point in the history
remotes: remove reference to pkg/errors
  • Loading branch information
carolynvs authored Mar 22, 2022
2 parents 154a018 + 3022fdc commit ce9f377
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions remotes/mount.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package remotes

import (
"context"
"errors"
"fmt"
"io"
"strings"
Expand All @@ -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 (
Expand Down Expand Up @@ -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")
Expand All @@ -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 {
Expand Down Expand Up @@ -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{})
}
Expand Down
4 changes: 2 additions & 2 deletions remotes/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package remotes
import (
"context"
"encoding/json"
"errors"
"fmt"
"io/ioutil"

Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions remotes/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"encoding/base64"
"encoding/json"
"errors"
"fmt"
"io"
"os"
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit ce9f377

Please sign in to comment.