Reused errdefs define error

Signed-off-by: yanggang <gang.yang@daocloud.io>
This commit is contained in:
yanggang 2022-12-27 11:09:23 +08:00
parent 3fefb98f99
commit b10536d64f
No known key found for this signature in database
GPG Key ID: 7F6E0CAD1556A240
2 changed files with 13 additions and 11 deletions

View File

@ -34,6 +34,7 @@ import (
"github.com/stretchr/testify/require"
"github.com/containerd/containerd/content"
"github.com/containerd/containerd/errdefs"
"github.com/opencontainers/go-digest"
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
@ -93,41 +94,41 @@ func (i fakeImage) ContentStore() content.Store {
func (i fakeImage) ReaderAt(ctx context.Context, dec ocispec.Descriptor) (content.ReaderAt, error) {
blob, found := i.blobs[dec.Digest.String()]
if !found {
return nil, errors.New("not found")
return nil, errdefs.ErrNotFound
}
return blob, nil
}
func (i fakeImage) Info(ctx context.Context, dgst digest.Digest) (content.Info, error) {
return content.Info{}, errors.New("not implemented")
return content.Info{}, errdefs.ErrNotImplemented
}
func (i fakeImage) Update(ctx context.Context, info content.Info, fieldpaths ...string) (content.Info, error) {
return content.Info{}, errors.New("not implemented")
return content.Info{}, errdefs.ErrNotImplemented
}
func (i fakeImage) Walk(ctx context.Context, fn content.WalkFunc, filters ...string) error {
return errors.New("not implemented")
return errdefs.ErrNotImplemented
}
func (i fakeImage) Delete(ctx context.Context, dgst digest.Digest) error {
return errors.New("not implemented")
return errdefs.ErrNotImplemented
}
func (i fakeImage) Status(ctx context.Context, ref string) (content.Status, error) {
return content.Status{}, errors.New("not implemented")
return content.Status{}, errdefs.ErrNotImplemented
}
func (i fakeImage) ListStatuses(ctx context.Context, filters ...string) ([]content.Status, error) {
return nil, errors.New("not implemented")
return nil, errdefs.ErrNotImplemented
}
func (i fakeImage) Abort(ctx context.Context, ref string) error {
return errors.New("not implemented")
return errdefs.ErrNotImplemented
}
func (i fakeImage) Writer(ctx context.Context, opts ...content.WriterOpt) (content.Writer, error) {
return nil, errors.New("not implemented")
return nil, errdefs.ErrNotImplemented
}
func TestReplaceOrAppendEnvValues(t *testing.T) {

View File

@ -26,6 +26,7 @@ import (
"fmt"
"strconv"
"github.com/containerd/containerd/errdefs"
bolt "go.etcd.io/bbolt"
)
@ -50,9 +51,9 @@ var (
var (
// ErrNotFound represents an error returned when object not found in meta store
ErrNotFound = errors.New("not found")
ErrNotFound = errdefs.ErrNotFound
// ErrAlreadyExists represents an error returned when object can't be duplicated in meta store
ErrAlreadyExists = errors.New("object already exists")
ErrAlreadyExists = errdefs.ErrAlreadyExists
)
// PoolMetadata keeps device info for the given thin-pool device, generates next available device ids,