forked from TrueCloudLab/frostfs-node
[#294] aclsvc: Refactor checker constructor
Pass required deps as args. Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
parent
7da284f3e8
commit
61541eaec2
3 changed files with 20 additions and 57 deletions
|
@ -21,35 +21,6 @@ import (
|
|||
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
||||
)
|
||||
|
||||
// CheckerPrm groups parameters for Checker
|
||||
// constructor.
|
||||
type CheckerPrm struct {
|
||||
eaclSrc container.EACLSource
|
||||
validator *eaclSDK.Validator
|
||||
localStorage *engine.StorageEngine
|
||||
state netmap.State
|
||||
}
|
||||
|
||||
func (c *CheckerPrm) SetEACLSource(v container.EACLSource) *CheckerPrm {
|
||||
c.eaclSrc = v
|
||||
return c
|
||||
}
|
||||
|
||||
func (c *CheckerPrm) SetValidator(v *eaclSDK.Validator) *CheckerPrm {
|
||||
c.validator = v
|
||||
return c
|
||||
}
|
||||
|
||||
func (c *CheckerPrm) SetLocalStorage(v *engine.StorageEngine) *CheckerPrm {
|
||||
c.localStorage = v
|
||||
return c
|
||||
}
|
||||
|
||||
func (c *CheckerPrm) SetNetmapState(v netmap.State) *CheckerPrm {
|
||||
c.state = v
|
||||
return c
|
||||
}
|
||||
|
||||
// Checker implements v2.ACLChecker interfaces and provides
|
||||
// ACL/eACL validation functionality.
|
||||
type Checker struct {
|
||||
|
@ -71,23 +42,17 @@ var (
|
|||
|
||||
// NewChecker creates Checker.
|
||||
// Panics if at least one of the parameter is nil.
|
||||
func NewChecker(prm *CheckerPrm) *Checker {
|
||||
panicOnNil := func(fieldName string, field any) {
|
||||
if field == nil {
|
||||
panic(fmt.Sprintf("incorrect field %s (%T): %v", fieldName, field, field))
|
||||
}
|
||||
}
|
||||
|
||||
panicOnNil("EACLSource", prm.eaclSrc)
|
||||
panicOnNil("EACLValidator", prm.validator)
|
||||
panicOnNil("LocalStorageEngine", prm.localStorage)
|
||||
panicOnNil("NetmapState", prm.state)
|
||||
|
||||
func NewChecker(
|
||||
state netmap.State,
|
||||
eaclSrc container.EACLSource,
|
||||
validator *eaclSDK.Validator,
|
||||
localStorage *engine.StorageEngine,
|
||||
) *Checker {
|
||||
return &Checker{
|
||||
eaclSrc: prm.eaclSrc,
|
||||
validator: prm.validator,
|
||||
localStorage: prm.localStorage,
|
||||
state: prm.state,
|
||||
eaclSrc: eaclSrc,
|
||||
validator: validator,
|
||||
localStorage: localStorage,
|
||||
state: state,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue