forked from TrueCloudLab/frostfs-node
[#203] Replace ErrEACLNotFound to core library
ErrEACLNotFound error was defined in implementation package. EACL validator checked this error after the call of eACL storage interface method. Replace ErrEACLNotFound to core container library. in order to: on the one hand not use an implementation error, on the other hand, to be able to reuse a generic type error (404). Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
621840d542
commit
fddc50fd85
4 changed files with 13 additions and 7 deletions
|
@ -22,3 +22,7 @@ type Source interface {
|
|||
|
||||
// ErrNotFound is the error returned when container was not found in storage.
|
||||
var ErrNotFound = errors.New("container not found")
|
||||
|
||||
// ErrEACLNotFound is returned by eACL storage implementations when
|
||||
// requested eACL table is not in storage.
|
||||
var ErrEACLNotFound = errors.New("extended ACL table is not set for this container")
|
||||
|
|
|
@ -2,16 +2,15 @@ package wrapper
|
|||
|
||||
import (
|
||||
"github.com/nspcc-dev/neofs-api-go/pkg/acl/eacl"
|
||||
"github.com/nspcc-dev/neofs-api-go/pkg/container"
|
||||
containerSDK "github.com/nspcc-dev/neofs-api-go/pkg/container"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/core/container"
|
||||
client "github.com/nspcc-dev/neofs-node/pkg/morph/client/container"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
var ErrEACLNotFound = errors.New("extended ACL table is not set for this container")
|
||||
|
||||
// GetEACL reads the extended ACL table from NeoFS system
|
||||
// through Container contract call.
|
||||
func (w *Wrapper) GetEACL(cid *container.ID) (*eacl.Table, []byte, error) {
|
||||
func (w *Wrapper) GetEACL(cid *containerSDK.ID) (*eacl.Table, []byte, error) {
|
||||
if cid == nil {
|
||||
return nil, nil, errNilArgument
|
||||
}
|
||||
|
@ -34,7 +33,7 @@ func (w *Wrapper) GetEACL(cid *container.ID) (*eacl.Table, []byte, error) {
|
|||
// since unsigned table cannot be approved in the storage by design.
|
||||
sig := rpcAnswer.Signature()
|
||||
if len(sig) == 0 {
|
||||
return nil, nil, ErrEACLNotFound
|
||||
return nil, nil, container.ErrEACLNotFound
|
||||
}
|
||||
|
||||
table := eacl.NewTable()
|
||||
|
|
|
@ -13,6 +13,9 @@ type Storage interface {
|
|||
// It returns any error encountered.
|
||||
//
|
||||
// GetEACL must return exactly one non-nil value.
|
||||
//
|
||||
// Must return pkg/core/container.ErrEACLNotFound if requested
|
||||
// eACL table is is not in storage.
|
||||
GetEACL(*container.ID) (*eacl.Table, error)
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ import (
|
|||
|
||||
"github.com/nspcc-dev/neofs-api-go/pkg/acl/eacl"
|
||||
crypto "github.com/nspcc-dev/neofs-crypto"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/morph/client/container/wrapper"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/core/container"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/util/logger"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
@ -68,7 +68,7 @@ func (v *Validator) CalculateAction(unit *ValidationUnit) eacl.Action {
|
|||
// get eACL table by container ID
|
||||
table, err = v.storage.GetEACL(unit.cid)
|
||||
if err != nil {
|
||||
if errors.Is(err, wrapper.ErrEACLNotFound) {
|
||||
if errors.Is(err, container.ErrEACLNotFound) {
|
||||
return eacl.ActionAllow
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue