From 4f18893d9b99095c71c390b566f582a52ca4a811 Mon Sep 17 00:00:00 2001 From: Pavel Karpy Date: Thu, 8 Sep 2022 13:32:25 +0300 Subject: [PATCH] [#1628] node: Move common `EACLSource` interface to `core` pkg Signed-off-by: Pavel Karpy --- cmd/neofs-node/cache.go | 3 +-- cmd/neofs-node/config.go | 3 +-- cmd/neofs-node/container.go | 3 +-- pkg/core/container/storage.go | 13 +++++++++++++ pkg/services/container/morph/executor.go | 3 +-- pkg/services/object/acl/acl.go | 8 ++++---- pkg/services/object/acl/eacl/types.go | 19 ------------------- 7 files changed, 21 insertions(+), 31 deletions(-) delete mode 100644 pkg/services/object/acl/eacl/types.go diff --git a/cmd/neofs-node/cache.go b/cmd/neofs-node/cache.go index 005a6a2d..25260e11 100644 --- a/cmd/neofs-node/cache.go +++ b/cmd/neofs-node/cache.go @@ -8,7 +8,6 @@ import ( "github.com/nspcc-dev/neofs-node/pkg/core/container" "github.com/nspcc-dev/neofs-node/pkg/core/netmap" cntClient "github.com/nspcc-dev/neofs-node/pkg/morph/client/container" - "github.com/nspcc-dev/neofs-node/pkg/services/object/acl/eacl" putsvc "github.com/nspcc-dev/neofs-node/pkg/services/object/put" apistatus "github.com/nspcc-dev/neofs-sdk-go/client/status" cid "github.com/nspcc-dev/neofs-sdk-go/container/id" @@ -162,7 +161,7 @@ func (s *ttlContainerStorage) Get(cnr cid.ID) (*container.Container, error) { type ttlEACLStorage ttlNetCache -func newCachedEACLStorage(v eacl.Source, ttl time.Duration) *ttlEACLStorage { +func newCachedEACLStorage(v container.EACLSource, ttl time.Duration) *ttlEACLStorage { const eaclCacheSize = 100 lruCnrCache := newNetworkTTLCache(eaclCacheSize, ttl, func(key interface{}) (interface{}, error) { diff --git a/cmd/neofs-node/config.go b/cmd/neofs-node/config.go index 9a2f3cc2..d8c11ace 100644 --- a/cmd/neofs-node/config.go +++ b/cmd/neofs-node/config.go @@ -40,7 +40,6 @@ import ( "github.com/nspcc-dev/neofs-node/pkg/network" "github.com/nspcc-dev/neofs-node/pkg/network/cache" "github.com/nspcc-dev/neofs-node/pkg/services/control" - "github.com/nspcc-dev/neofs-node/pkg/services/object/acl/eacl" getsvc "github.com/nspcc-dev/neofs-node/pkg/services/object/get" "github.com/nspcc-dev/neofs-node/pkg/services/object_manager/tombstone" tsourse "github.com/nspcc-dev/neofs-node/pkg/services/object_manager/tombstone/source" @@ -195,7 +194,7 @@ type cfgObject struct { cnrSource container.Source - eaclSource eacl.Source + eaclSource container.EACLSource pool cfgObjectRoutines diff --git a/cmd/neofs-node/container.go b/cmd/neofs-node/container.go index 056e024b..d271a11b 100644 --- a/cmd/neofs-node/container.go +++ b/cmd/neofs-node/container.go @@ -25,7 +25,6 @@ import ( placementrouter "github.com/nspcc-dev/neofs-node/pkg/services/container/announcement/load/route/placement" loadstorage "github.com/nspcc-dev/neofs-node/pkg/services/container/announcement/load/storage" containerMorph "github.com/nspcc-dev/neofs-node/pkg/services/container/morph" - "github.com/nspcc-dev/neofs-node/pkg/services/object/acl/eacl" "github.com/nspcc-dev/neofs-node/pkg/util/logger" apiClient "github.com/nspcc-dev/neofs-sdk-go/client" containerSDK "github.com/nspcc-dev/neofs-sdk-go/container" @@ -619,7 +618,7 @@ func (c *usedSpaceService) processLoadValue(_ context.Context, a containerSDK.Si // implements interface required by container service provided by morph executor. type morphContainerReader struct { - eacl eacl.Source + eacl containerCore.EACLSource get containerCore.Source diff --git a/pkg/core/container/storage.go b/pkg/core/container/storage.go index 18478c31..3c83bb64 100644 --- a/pkg/core/container/storage.go +++ b/pkg/core/container/storage.go @@ -55,3 +55,16 @@ type EACL struct { // Session within which Value was set. Nil means session absence. Session *session.Container } + +// EACLSource is the interface that wraps +// basic methods of extended ACL table source. +type EACLSource interface { + // GetEACL reads the table from the source by identifier. + // It returns any error encountered. + // + // GetEACL must return exactly one non-nil value. + // + // Must return apistatus.ErrEACLNotFound if requested + // eACL table is not in source. + GetEACL(cid.ID) (*EACL, error) +} diff --git a/pkg/services/container/morph/executor.go b/pkg/services/container/morph/executor.go index dd7dc072..22c5f7be 100644 --- a/pkg/services/container/morph/executor.go +++ b/pkg/services/container/morph/executor.go @@ -10,7 +10,6 @@ import ( sessionV2 "github.com/nspcc-dev/neofs-api-go/v2/session" containercore "github.com/nspcc-dev/neofs-node/pkg/core/container" containerSvc "github.com/nspcc-dev/neofs-node/pkg/services/container" - "github.com/nspcc-dev/neofs-node/pkg/services/object/acl/eacl" cid "github.com/nspcc-dev/neofs-sdk-go/container/id" eaclSDK "github.com/nspcc-dev/neofs-sdk-go/eacl" "github.com/nspcc-dev/neofs-sdk-go/session" @@ -25,7 +24,7 @@ type morphExecutor struct { // Reader is an interface of read-only container storage. type Reader interface { containercore.Source - eacl.Source + containercore.EACLSource // List returns a list of container identifiers belonging // to the specified user of NeoFS system. Returns the identifiers diff --git a/pkg/services/object/acl/acl.go b/pkg/services/object/acl/acl.go index 2c8793cd..59c7aee6 100644 --- a/pkg/services/object/acl/acl.go +++ b/pkg/services/object/acl/acl.go @@ -7,9 +7,9 @@ import ( "fmt" "github.com/nspcc-dev/neo-go/pkg/crypto/keys" + "github.com/nspcc-dev/neofs-node/pkg/core/container" "github.com/nspcc-dev/neofs-node/pkg/core/netmap" "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/engine" - "github.com/nspcc-dev/neofs-node/pkg/services/object/acl/eacl" eaclV2 "github.com/nspcc-dev/neofs-node/pkg/services/object/acl/eacl/v2" v2 "github.com/nspcc-dev/neofs-node/pkg/services/object/acl/v2" bearerSDK "github.com/nspcc-dev/neofs-sdk-go/bearer" @@ -23,13 +23,13 @@ import ( // CheckerPrm groups parameters for Checker // constructor. type CheckerPrm struct { - eaclSrc eacl.Source + eaclSrc container.EACLSource validator *eaclSDK.Validator localStorage *engine.StorageEngine state netmap.State } -func (c *CheckerPrm) SetEACLSource(v eacl.Source) *CheckerPrm { +func (c *CheckerPrm) SetEACLSource(v container.EACLSource) *CheckerPrm { c.eaclSrc = v return c } @@ -52,7 +52,7 @@ func (c *CheckerPrm) SetNetmapState(v netmap.State) *CheckerPrm { // Checker implements v2.ACLChecker interfaces and provides // ACL/eACL validation functionality. type Checker struct { - eaclSrc eacl.Source + eaclSrc container.EACLSource validator *eaclSDK.Validator localStorage *engine.StorageEngine state netmap.State diff --git a/pkg/services/object/acl/eacl/types.go b/pkg/services/object/acl/eacl/types.go deleted file mode 100644 index 4abd992d..00000000 --- a/pkg/services/object/acl/eacl/types.go +++ /dev/null @@ -1,19 +0,0 @@ -package eacl - -import ( - containercore "github.com/nspcc-dev/neofs-node/pkg/core/container" - cid "github.com/nspcc-dev/neofs-sdk-go/container/id" -) - -// Source is the interface that wraps -// basic methods of extended ACL table source. -type Source interface { - // GetEACL reads the table from the source by identifier. - // It returns any error encountered. - // - // GetEACL must return exactly one non-nil value. - // - // Must return apistatus.ErrEACLNotFound if requested - // eACL table is not in source. - GetEACL(cid.ID) (*containercore.EACL, error) -}