From f00ca1b6c475f37e1da54fe99d829d232ccf837a Mon Sep 17 00:00:00 2001 From: Denis Kirillov Date: Mon, 6 Jun 2022 14:09:09 +0300 Subject: [PATCH] [#438] Drop layer/neofs package Signed-off-by: Denis Kirillov --- api/handler/handlers_test.go | 12 +++--- api/layer/container.go | 3 +- api/layer/layer.go | 7 ++-- api/layer/{neofs => }/neofs.go | 2 +- .../neofstest => api/layer}/neofs_mock.go | 26 ++++-------- api/layer/object.go | 17 ++++---- api/layer/system_object.go | 3 +- api/layer/versioning_test.go | 8 ++-- internal/neofs/neofs.go | 40 +++++++++---------- internal/neofs/neofs_test.go | 6 +-- 10 files changed, 53 insertions(+), 71 deletions(-) rename api/layer/{neofs => }/neofs.go (99%) rename {internal/neofstest => api/layer}/neofs_mock.go (88%) diff --git a/api/handler/handlers_test.go b/api/handler/handlers_test.go index bf7b41d..b5f81a4 100644 --- a/api/handler/handlers_test.go +++ b/api/handler/handlers_test.go @@ -16,9 +16,7 @@ import ( "github.com/nspcc-dev/neofs-s3-gw/api" "github.com/nspcc-dev/neofs-s3-gw/api/data" "github.com/nspcc-dev/neofs-s3-gw/api/layer" - "github.com/nspcc-dev/neofs-s3-gw/api/layer/neofs" "github.com/nspcc-dev/neofs-s3-gw/api/resolver" - "github.com/nspcc-dev/neofs-s3-gw/internal/neofstest" cid "github.com/nspcc-dev/neofs-sdk-go/container/id" "github.com/nspcc-dev/neofs-sdk-go/object" "github.com/nspcc-dev/neofs-sdk-go/user" @@ -28,14 +26,14 @@ import ( type handlerContext struct { h *handler - tp *neofstest.TestNeoFS + tp *layer.TestNeoFS } func (hc *handlerContext) Handler() *handler { return hc.h } -func (hc *handlerContext) MockedPool() *neofstest.TestNeoFS { +func (hc *handlerContext) MockedPool() *layer.TestNeoFS { return hc.tp } @@ -48,7 +46,7 @@ func prepareHandlerContext(t *testing.T) *handlerContext { require.NoError(t, err) l := zap.NewNop() - tp := neofstest.NewTestNeoFS() + tp := layer.NewTestNeoFS() testResolver := &resolver.BucketResolver{Name: "test_resolver"} testResolver.SetResolveFunc(func(_ context.Context, name string) (*cid.ID, error) { @@ -74,14 +72,14 @@ func prepareHandlerContext(t *testing.T) *handlerContext { } func createTestBucket(ctx context.Context, t *testing.T, h *handlerContext, bktName string) { - _, err := h.MockedPool().CreateContainer(ctx, neofs.PrmContainerCreate{ + _, err := h.MockedPool().CreateContainer(ctx, layer.PrmContainerCreate{ Name: bktName, }) require.NoError(t, err) } func createTestBucketWithLock(ctx context.Context, t *testing.T, h *handlerContext, bktName string, conf *data.ObjectLockConfiguration) *data.BucketInfo { - cnrID, err := h.MockedPool().CreateContainer(ctx, neofs.PrmContainerCreate{ + cnrID, err := h.MockedPool().CreateContainer(ctx, layer.PrmContainerCreate{ Name: bktName, AdditionalAttributes: [][2]string{{layer.AttributeLockEnabled, "true"}}, }) diff --git a/api/layer/container.go b/api/layer/container.go index d59b3fa..003ffef 100644 --- a/api/layer/container.go +++ b/api/layer/container.go @@ -8,7 +8,6 @@ import ( "github.com/nspcc-dev/neofs-s3-gw/api" "github.com/nspcc-dev/neofs-s3-gw/api/data" "github.com/nspcc-dev/neofs-s3-gw/api/errors" - "github.com/nspcc-dev/neofs-s3-gw/api/layer/neofs" "github.com/nspcc-dev/neofs-sdk-go/acl" "github.com/nspcc-dev/neofs-sdk-go/client" "github.com/nspcc-dev/neofs-sdk-go/container" @@ -147,7 +146,7 @@ func (n *layer) createContainer(ctx context.Context, p *CreateBucketParams) (*da }) } - idCnr, err := n.neoFS.CreateContainer(ctx, neofs.PrmContainerCreate{ + idCnr, err := n.neoFS.CreateContainer(ctx, PrmContainerCreate{ Creator: bktInfo.Owner, Policy: *p.Policy, Name: p.Name, diff --git a/api/layer/layer.go b/api/layer/layer.go index fe85918..14bc9ae 100644 --- a/api/layer/layer.go +++ b/api/layer/layer.go @@ -15,7 +15,6 @@ import ( "github.com/nspcc-dev/neofs-s3-gw/api/cache" "github.com/nspcc-dev/neofs-s3-gw/api/data" "github.com/nspcc-dev/neofs-s3-gw/api/errors" - "github.com/nspcc-dev/neofs-s3-gw/api/layer/neofs" "github.com/nspcc-dev/neofs-s3-gw/api/resolver" "github.com/nspcc-dev/neofs-s3-gw/creds/accessbox" "github.com/nspcc-dev/neofs-sdk-go/bearer" @@ -41,7 +40,7 @@ type ( MsgHandlerFunc func(context.Context, *nats.Msg) error layer struct { - neoFS neofs.NeoFS + neoFS NeoFS log *zap.Logger anonKey AnonymousKey resolver *resolver.BucketResolver @@ -271,7 +270,7 @@ func DefaultCachesConfigs() *CachesConfig { // NewLayer creates an instance of a layer. It checks credentials // and establishes gRPC connection with the node. -func NewLayer(log *zap.Logger, neoFS neofs.NeoFS, config *Config) Client { +func NewLayer(log *zap.Logger, neoFS NeoFS, config *Config) Client { return &layer{ neoFS: neoFS, log: log, @@ -324,7 +323,7 @@ func (n *layer) Owner(ctx context.Context) user.ID { return ownerID } -func (n *layer) prepareAuthParameters(ctx context.Context, prm *neofs.PrmAuth, bktOwner user.ID) { +func (n *layer) prepareAuthParameters(ctx context.Context, prm *PrmAuth, bktOwner user.ID) { if bd, ok := ctx.Value(api.BoxData).(*accessbox.Box); ok && bd != nil && bd.Gate != nil && bd.Gate.BearerToken != nil { if bktOwner.Equals(bearer.ResolveIssuer(*bd.Gate.BearerToken)) { prm.BearerToken = bd.Gate.BearerToken diff --git a/api/layer/neofs/neofs.go b/api/layer/neofs.go similarity index 99% rename from api/layer/neofs/neofs.go rename to api/layer/neofs.go index 6bfd5e2..de73f3d 100644 --- a/api/layer/neofs/neofs.go +++ b/api/layer/neofs.go @@ -1,4 +1,4 @@ -package neofs +package layer import ( "context" diff --git a/internal/neofstest/neofs_mock.go b/api/layer/neofs_mock.go similarity index 88% rename from internal/neofstest/neofs_mock.go rename to api/layer/neofs_mock.go index 1ab7cd2..da5358e 100644 --- a/internal/neofstest/neofs_mock.go +++ b/api/layer/neofs_mock.go @@ -1,4 +1,4 @@ -package neofstest +package layer import ( "bytes" @@ -12,7 +12,6 @@ import ( "time" objectv2 "github.com/nspcc-dev/neofs-api-go/v2/object" - "github.com/nspcc-dev/neofs-s3-gw/api/layer/neofs" "github.com/nspcc-dev/neofs-sdk-go/checksum" "github.com/nspcc-dev/neofs-sdk-go/container" cid "github.com/nspcc-dev/neofs-sdk-go/container/id" @@ -21,10 +20,8 @@ import ( "github.com/nspcc-dev/neofs-sdk-go/user" ) -const objectSystemAttributeName = "S3-System-name" - type TestNeoFS struct { - neofs.NeoFS + NeoFS objects map[string]*object.Object containers map[string]*container.Container @@ -68,7 +65,7 @@ func (t *TestNeoFS) ContainerID(name string) (*cid.ID, error) { return nil, fmt.Errorf("not found") } -func (t *TestNeoFS) CreateContainer(_ context.Context, prm neofs.PrmContainerCreate) (*cid.ID, error) { +func (t *TestNeoFS) CreateContainer(_ context.Context, prm PrmContainerCreate) (*cid.ID, error) { opts := []container.Option{ container.WithOwnerID(&prm.Creator), container.WithPolicy(&prm.Policy), @@ -126,7 +123,7 @@ func (t *TestNeoFS) UserContainers(_ context.Context, _ user.ID) ([]cid.ID, erro return res, nil } -func (t *TestNeoFS) SelectObjects(_ context.Context, prm neofs.PrmObjectSelect) ([]oid.ID, error) { +func (t *TestNeoFS) SelectObjects(_ context.Context, prm PrmObjectSelect) ([]oid.ID, error) { filters := object.NewSearchFilters() filters.AddRootFilter() @@ -168,7 +165,7 @@ func (t *TestNeoFS) SelectObjects(_ context.Context, prm neofs.PrmObjectSelect) return res, nil } -func (t *TestNeoFS) ReadObject(_ context.Context, prm neofs.PrmObjectRead) (*neofs.ObjectPart, error) { +func (t *TestNeoFS) ReadObject(_ context.Context, prm PrmObjectRead) (*ObjectPart, error) { var addr oid.Address addr.SetContainer(prm.Container) addr.SetObject(prm.Object) @@ -176,7 +173,7 @@ func (t *TestNeoFS) ReadObject(_ context.Context, prm neofs.PrmObjectRead) (*neo sAddr := addr.EncodeToString() if obj, ok := t.objects[sAddr]; ok { - return &neofs.ObjectPart{ + return &ObjectPart{ Head: obj, Payload: io.NopCloser(bytes.NewReader(obj.Payload())), }, nil @@ -185,7 +182,7 @@ func (t *TestNeoFS) ReadObject(_ context.Context, prm neofs.PrmObjectRead) (*neo return nil, fmt.Errorf("object not found %s", addr) } -func (t *TestNeoFS) CreateObject(_ context.Context, prm neofs.PrmObjectCreate) (*oid.ID, error) { +func (t *TestNeoFS) CreateObject(_ context.Context, prm PrmObjectCreate) (*oid.ID, error) { b := make([]byte, 32) if _, err := io.ReadFull(rand.Reader, b); err != nil { return nil, err @@ -243,7 +240,7 @@ func (t *TestNeoFS) CreateObject(_ context.Context, prm neofs.PrmObjectCreate) ( return &objID, nil } -func (t *TestNeoFS) DeleteObject(_ context.Context, prm neofs.PrmObjectDelete) error { +func (t *TestNeoFS) DeleteObject(_ context.Context, prm PrmObjectDelete) error { var addr oid.Address addr.SetContainer(prm.Container) addr.SetObject(prm.Object) @@ -266,10 +263,3 @@ func isMatched(attributes []object.Attribute, filter object.SearchFilter) bool { return false } - -func newAddress(cnr cid.ID, obj oid.ID) oid.Address { - var addr oid.Address - addr.SetContainer(cnr) - addr.SetObject(obj) - return addr -} diff --git a/api/layer/object.go b/api/layer/object.go index 7714d7b..2eb81e8 100644 --- a/api/layer/object.go +++ b/api/layer/object.go @@ -15,7 +15,6 @@ import ( "github.com/nspcc-dev/neofs-s3-gw/api/cache" "github.com/nspcc-dev/neofs-s3-gw/api/data" apiErrors "github.com/nspcc-dev/neofs-s3-gw/api/errors" - "github.com/nspcc-dev/neofs-s3-gw/api/layer/neofs" "github.com/nspcc-dev/neofs-s3-gw/internal/misc" "github.com/nspcc-dev/neofs-sdk-go/client" cid "github.com/nspcc-dev/neofs-sdk-go/container/id" @@ -79,7 +78,7 @@ func (n *layer) objectSearchByName(ctx context.Context, bktInfo *data.BucketInfo // objectSearch returns all available objects by search params. func (n *layer) objectSearch(ctx context.Context, p *findParams) ([]oid.ID, error) { - prm := neofs.PrmObjectSelect{ + prm := PrmObjectSelect{ Container: p.bkt.CID, ExactAttribute: p.attr, FilePrefix: p.prefix, @@ -101,7 +100,7 @@ func newAddress(cnr cid.ID, obj oid.ID) oid.Address { // objectHead returns all object's headers. func (n *layer) objectHead(ctx context.Context, bktInfo *data.BucketInfo, idObj oid.ID) (*object.Object, error) { - prm := neofs.PrmObjectRead{ + prm := PrmObjectRead{ Container: bktInfo.CID, Object: idObj, WithHeader: true, @@ -120,7 +119,7 @@ func (n *layer) objectHead(ctx context.Context, bktInfo *data.BucketInfo, idObj // initializes payload reader of the NeoFS object. // Zero range corresponds to full payload (panics if only offset is set). func (n *layer) initObjectPayloadReader(ctx context.Context, p getParams) (io.Reader, error) { - prm := neofs.PrmObjectRead{ + prm := PrmObjectRead{ Container: p.objInfo.CID, Object: p.objInfo.ID, WithPayload: true, @@ -139,7 +138,7 @@ func (n *layer) initObjectPayloadReader(ctx context.Context, p getParams) (io.Re // objectGet returns an object with payload in the object. func (n *layer) objectGet(ctx context.Context, bktInfo *data.BucketInfo, objID oid.ID) (*object.Object, error) { - prm := neofs.PrmObjectRead{ + prm := PrmObjectRead{ Container: bktInfo.CID, Object: objID, WithHeader: true, @@ -178,7 +177,7 @@ func (n *layer) PutObject(ctx context.Context, p *PutObjectParams) (*data.Object } } - prm := neofs.PrmObjectCreate{ + prm := PrmObjectCreate{ Container: p.BktInfo.CID, Creator: own, PayloadSize: uint64(p.Size), @@ -439,7 +438,7 @@ func (n *layer) headVersion(ctx context.Context, bkt *data.BucketInfo, p *HeadOb // objectDelete puts tombstone object into neofs. func (n *layer) objectDelete(ctx context.Context, bktInfo *data.BucketInfo, idObj oid.ID) error { - prm := neofs.PrmObjectDelete{ + prm := PrmObjectDelete{ Container: bktInfo.CID, Object: idObj, } @@ -453,7 +452,7 @@ func (n *layer) objectDelete(ctx context.Context, bktInfo *data.BucketInfo, idOb // objectPutAndHash prepare auth parameters and invoke neofs.CreateObject. // Returns object ID and payload sha256 hash. -func (n *layer) objectPutAndHash(ctx context.Context, prm neofs.PrmObjectCreate, bktInfo *data.BucketInfo) (*oid.ID, []byte, error) { +func (n *layer) objectPutAndHash(ctx context.Context, prm PrmObjectCreate, bktInfo *data.BucketInfo) (*oid.ID, []byte, error) { n.prepareAuthParameters(ctx, &prm.PrmAuth, bktInfo.Owner) hash := sha256.New() prm.Payload = wrapReader(prm.Payload, 64*1024, func(buf []byte) { @@ -705,7 +704,7 @@ func (n *layer) transformNeofsError(ctx context.Context, err error) error { return nil } - if errors.Is(err, neofs.ErrAccessDenied) { + if errors.Is(err, ErrAccessDenied) { n.log.Debug("error was transformed", zap.String("request_id", api.GetRequestID(ctx)), zap.Error(err)) return apiErrors.GetAPIError(apiErrors.ErrAccessDenied) } diff --git a/api/layer/system_object.go b/api/layer/system_object.go index eb4e3e4..8b7f3a9 100644 --- a/api/layer/system_object.go +++ b/api/layer/system_object.go @@ -12,7 +12,6 @@ import ( "github.com/nspcc-dev/neofs-s3-gw/api/data" "github.com/nspcc-dev/neofs-s3-gw/api/errors" - "github.com/nspcc-dev/neofs-s3-gw/api/layer/neofs" "github.com/nspcc-dev/neofs-s3-gw/internal/misc" "github.com/nspcc-dev/neofs-sdk-go/object" "go.uber.org/zap" @@ -85,7 +84,7 @@ func (n *layer) putSystemObjectIntoNeoFS(ctx context.Context, p *PutSystemObject idsToDeleteArr := updateCRDT2PSetHeaders(p.Metadata, versions, false) // false means "last write wins" // note that updateCRDT2PSetHeaders modifies p.Metadata and must be called further processing - prm := neofs.PrmObjectCreate{ + prm := PrmObjectCreate{ Container: p.BktInfo.CID, Creator: p.BktInfo.Owner, Attributes: make([][2]string, 2, 2+len(p.Metadata)), diff --git a/api/layer/versioning_test.go b/api/layer/versioning_test.go index f1b1d53..d9f7157 100644 --- a/api/layer/versioning_test.go +++ b/api/layer/versioning_test.go @@ -10,9 +10,7 @@ import ( "github.com/nspcc-dev/neo-go/pkg/crypto/keys" "github.com/nspcc-dev/neofs-s3-gw/api" "github.com/nspcc-dev/neofs-s3-gw/api/data" - "github.com/nspcc-dev/neofs-s3-gw/api/layer/neofs" "github.com/nspcc-dev/neofs-s3-gw/creds/accessbox" - "github.com/nspcc-dev/neofs-s3-gw/internal/neofstest" bearertest "github.com/nspcc-dev/neofs-sdk-go/bearer/test" "github.com/nspcc-dev/neofs-sdk-go/object" oid "github.com/nspcc-dev/neofs-sdk-go/object/id" @@ -134,7 +132,7 @@ type testContext struct { layer Client bktInfo *data.BucketInfo obj string - testNeoFS *neofstest.TestNeoFS + testNeoFS *TestNeoFS } func prepareContext(t *testing.T, cachesConfig ...*CachesConfig) *testContext { @@ -150,10 +148,10 @@ func prepareContext(t *testing.T, cachesConfig ...*CachesConfig) *testContext { GateKey: key.PublicKey(), }, }) - tp := neofstest.NewTestNeoFS() + tp := NewTestNeoFS() bktName := "testbucket1" - bktID, err := tp.CreateContainer(ctx, neofs.PrmContainerCreate{ + bktID, err := tp.CreateContainer(ctx, PrmContainerCreate{ Name: bktName, }) require.NoError(t, err) diff --git a/internal/neofs/neofs.go b/internal/neofs/neofs.go index a31fd48..b3b5e73 100644 --- a/internal/neofs/neofs.go +++ b/internal/neofs/neofs.go @@ -13,7 +13,7 @@ import ( "github.com/nspcc-dev/neo-go/pkg/vm/stackitem" objectv2 "github.com/nspcc-dev/neofs-api-go/v2/object" - "github.com/nspcc-dev/neofs-s3-gw/api/layer/neofs" + "github.com/nspcc-dev/neofs-s3-gw/api/layer" "github.com/nspcc-dev/neofs-s3-gw/authmate" "github.com/nspcc-dev/neofs-s3-gw/creds/tokens" apistatus "github.com/nspcc-dev/neofs-sdk-go/client/status" @@ -119,7 +119,7 @@ func (x *NeoFS) Container(ctx context.Context, idCnr cid.ID) (*container.Contain } // CreateContainer implements neofs.NeoFS interface method. -func (x *NeoFS) CreateContainer(ctx context.Context, prm neofs.PrmContainerCreate) (*cid.ID, error) { +func (x *NeoFS) CreateContainer(ctx context.Context, prm layer.PrmContainerCreate) (*cid.ID, error) { // fill container structure cnrOptions := []container.Option{ container.WithPolicy(&prm.Policy), @@ -222,7 +222,7 @@ func (x *NeoFS) DeleteContainer(ctx context.Context, id cid.ID, token *session.C } // CreateObject implements neofs.NeoFS interface method. -func (x *NeoFS) CreateObject(ctx context.Context, prm neofs.PrmObjectCreate) (*oid.ID, error) { +func (x *NeoFS) CreateObject(ctx context.Context, prm layer.PrmObjectCreate) (*oid.ID, error) { attrNum := len(prm.Attributes) + 1 // + creation time if prm.Filename != "" { @@ -282,7 +282,7 @@ func (x *NeoFS) CreateObject(ctx context.Context, prm neofs.PrmObjectCreate) (*o } // SelectObjects implements neofs.NeoFS interface method. -func (x *NeoFS) SelectObjects(ctx context.Context, prm neofs.PrmObjectSelect) ([]oid.ID, error) { +func (x *NeoFS) SelectObjects(ctx context.Context, prm layer.PrmObjectSelect) ([]oid.ID, error) { filters := object.NewSearchFilters() filters.AddRootFilter() @@ -319,7 +319,7 @@ func (x *NeoFS) SelectObjects(ctx context.Context, prm neofs.PrmObjectSelect) ([ }) if err != nil { if reason, ok := isErrAccessDenied(err); ok { - return nil, fmt.Errorf("%w: %s", neofs.ErrAccessDenied, reason) + return nil, fmt.Errorf("%w: %s", layer.ErrAccessDenied, reason) } return nil, fmt.Errorf("read object list: %w", err) @@ -338,7 +338,7 @@ func (x payloadReader) Read(p []byte) (int, error) { n, err := x.ReadCloser.Read(p) if err != nil { if reason, ok := isErrAccessDenied(err); ok { - return n, fmt.Errorf("%w: %s", neofs.ErrAccessDenied, reason) + return n, fmt.Errorf("%w: %s", layer.ErrAccessDenied, reason) } } @@ -346,7 +346,7 @@ func (x payloadReader) Read(p []byte) (int, error) { } // ReadObject implements neofs.NeoFS interface method. -func (x *NeoFS) ReadObject(ctx context.Context, prm neofs.PrmObjectRead) (*neofs.ObjectPart, error) { +func (x *NeoFS) ReadObject(ctx context.Context, prm layer.PrmObjectRead) (*layer.ObjectPart, error) { var addr oid.Address addr.SetContainer(prm.Container) addr.SetObject(prm.Object) @@ -365,7 +365,7 @@ func (x *NeoFS) ReadObject(ctx context.Context, prm neofs.PrmObjectRead) (*neofs res, err := x.pool.GetObject(ctx, prmGet) if err != nil { if reason, ok := isErrAccessDenied(err); ok { - return nil, fmt.Errorf("%w: %s", neofs.ErrAccessDenied, reason) + return nil, fmt.Errorf("%w: %s", layer.ErrAccessDenied, reason) } return nil, fmt.Errorf("init full object reading via connection pool: %w", err) @@ -380,7 +380,7 @@ func (x *NeoFS) ReadObject(ctx context.Context, prm neofs.PrmObjectRead) (*neofs res.Header.SetPayload(payload) - return &neofs.ObjectPart{ + return &layer.ObjectPart{ Head: &res.Header, }, nil } @@ -397,26 +397,26 @@ func (x *NeoFS) ReadObject(ctx context.Context, prm neofs.PrmObjectRead) (*neofs hdr, err := x.pool.HeadObject(ctx, prmHead) if err != nil { if reason, ok := isErrAccessDenied(err); ok { - return nil, fmt.Errorf("%w: %s", neofs.ErrAccessDenied, reason) + return nil, fmt.Errorf("%w: %s", layer.ErrAccessDenied, reason) } return nil, fmt.Errorf("read object header via connection pool: %w", err) } - return &neofs.ObjectPart{ + return &layer.ObjectPart{ Head: hdr, }, nil } else if prm.PayloadRange[0]+prm.PayloadRange[1] == 0 { res, err := x.pool.GetObject(ctx, prmGet) if err != nil { if reason, ok := isErrAccessDenied(err); ok { - return nil, fmt.Errorf("%w: %s", neofs.ErrAccessDenied, reason) + return nil, fmt.Errorf("%w: %s", layer.ErrAccessDenied, reason) } return nil, fmt.Errorf("init full payload range reading via connection pool: %w", err) } - return &neofs.ObjectPart{ + return &layer.ObjectPart{ Payload: res.Payload, }, nil } @@ -435,19 +435,19 @@ func (x *NeoFS) ReadObject(ctx context.Context, prm neofs.PrmObjectRead) (*neofs res, err := x.pool.ObjectRange(ctx, prmRange) if err != nil { if reason, ok := isErrAccessDenied(err); ok { - return nil, fmt.Errorf("%w: %s", neofs.ErrAccessDenied, reason) + return nil, fmt.Errorf("%w: %s", layer.ErrAccessDenied, reason) } return nil, fmt.Errorf("init payload range reading via connection pool: %w", err) } - return &neofs.ObjectPart{ + return &layer.ObjectPart{ Payload: payloadReader{res}, }, nil } // DeleteObject implements neofs.NeoFS interface method. -func (x *NeoFS) DeleteObject(ctx context.Context, prm neofs.PrmObjectDelete) error { +func (x *NeoFS) DeleteObject(ctx context.Context, prm layer.PrmObjectDelete) error { var addr oid.Address addr.SetContainer(prm.Container) addr.SetObject(prm.Object) @@ -464,7 +464,7 @@ func (x *NeoFS) DeleteObject(ctx context.Context, prm neofs.PrmObjectDelete) err err := x.pool.DeleteObject(ctx, prmDelete) if err != nil { if reason, ok := isErrAccessDenied(err); ok { - return fmt.Errorf("%w: %s", neofs.ErrAccessDenied, reason) + return fmt.Errorf("%w: %s", layer.ErrAccessDenied, reason) } return fmt.Errorf("mark object removal via connection pool: %w", err) @@ -547,7 +547,7 @@ func (x *AuthmateNeoFS) TimeToEpoch(ctx context.Context, futureTime time.Time) ( // CreateContainer implements authmate.NeoFS interface method. func (x *AuthmateNeoFS) CreateContainer(ctx context.Context, prm authmate.PrmContainerCreate) (*cid.ID, error) { - return x.neoFS.CreateContainer(ctx, neofs.PrmContainerCreate{ + return x.neoFS.CreateContainer(ctx, layer.PrmContainerCreate{ Creator: prm.Owner, Policy: prm.Policy, Name: prm.FriendlyName, @@ -557,7 +557,7 @@ func (x *AuthmateNeoFS) CreateContainer(ctx context.Context, prm authmate.PrmCon // ReadObjectPayload implements authmate.NeoFS interface method. func (x *AuthmateNeoFS) ReadObjectPayload(ctx context.Context, addr oid.Address) ([]byte, error) { - res, err := x.neoFS.ReadObject(ctx, neofs.PrmObjectRead{ + res, err := x.neoFS.ReadObject(ctx, layer.PrmObjectRead{ Container: addr.Container(), Object: addr.Object(), WithPayload: true, @@ -573,7 +573,7 @@ func (x *AuthmateNeoFS) ReadObjectPayload(ctx context.Context, addr oid.Address) // CreateObject implements authmate.NeoFS interface method. func (x *AuthmateNeoFS) CreateObject(ctx context.Context, prm tokens.PrmObjectCreate) (*oid.ID, error) { - return x.neoFS.CreateObject(ctx, neofs.PrmObjectCreate{ + return x.neoFS.CreateObject(ctx, layer.PrmObjectCreate{ Creator: prm.Creator, Container: prm.Container, Filename: prm.Filename, diff --git a/internal/neofs/neofs_test.go b/internal/neofs/neofs_test.go index 04f56cc..f83b188 100644 --- a/internal/neofs/neofs_test.go +++ b/internal/neofs/neofs_test.go @@ -4,7 +4,7 @@ import ( "fmt" "testing" - "github.com/nspcc-dev/neofs-s3-gw/api/layer/neofs" + "github.com/nspcc-dev/neofs-s3-gw/api/layer" apistatus "github.com/nspcc-dev/neofs-sdk-go/client/status" "github.com/stretchr/testify/require" ) @@ -17,9 +17,9 @@ func TestErrorChecking(t *testing.T) { var wrappedError error if fetchedReason, ok := isErrAccessDenied(err); ok { - wrappedError = fmt.Errorf("%w: %s", neofs.ErrAccessDenied, fetchedReason) + wrappedError = fmt.Errorf("%w: %s", layer.ErrAccessDenied, fetchedReason) } - require.ErrorIs(t, wrappedError, neofs.ErrAccessDenied) + require.ErrorIs(t, wrappedError, layer.ErrAccessDenied) require.Contains(t, wrappedError.Error(), reason) }