Skip to content

Commit

Permalink
layer: Remove gateSigner
Browse files Browse the repository at this point in the history
Signed-off-by: Evgenii Baidakov <[email protected]>
  • Loading branch information
smallhive committed Aug 11, 2023
1 parent 0775e3b commit 4a66ae8
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 14 deletions.
2 changes: 1 addition & 1 deletion api/layer/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ func (n *layer) createContainer(ctx context.Context, p *CreateBucketParams) (*da
func (n *layer) setContainerEACLTable(ctx context.Context, idCnr cid.ID, table *eacl.Table, sessionToken *session.Container) error {
table.SetCID(idCnr)

return n.neoFS.SetContainerEACL(ctx, *table, sessionToken, n.gateSigner)
return n.neoFS.SetContainerEACL(ctx, *table, sessionToken)
}

func (n *layer) GetContainerEACL(ctx context.Context, idCnr cid.ID) (*eacl.Table, error) {
Expand Down
8 changes: 3 additions & 5 deletions api/layer/layer.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,8 @@ type (
MsgHandlerFunc func(context.Context, *nats.Msg) error

layer struct {
neoFS NeoFS
log *zap.Logger
gateSigner user.Signer
neoFS NeoFS
log *zap.Logger
// used in case of user wants to do something like anonymous.
// Typical using is a flag --no-sign-request in aws-cli.
anonymous user.ID
Expand Down Expand Up @@ -265,7 +264,6 @@ func NewLayer(log *zap.Logger, neoFS NeoFS, config *Config) Client {
return &layer{
neoFS: neoFS,
log: log,
gateSigner: user.NewAutoIDSignerRFC6979(config.GateKey.PrivateKey),
anonymous: config.Anonymous,
resolver: config.Resolver,
cache: NewCache(config.Caches),
Expand Down Expand Up @@ -666,5 +664,5 @@ func (n *layer) DeleteBucket(ctx context.Context, p *DeleteBucketParams) error {
}

n.cache.DeleteBucket(p.BktInfo.Name)
return n.neoFS.DeleteContainer(ctx, p.BktInfo.CID, p.SessionToken, n.gateSigner)
return n.neoFS.DeleteContainer(ctx, p.BktInfo.CID, p.SessionToken)
}
4 changes: 2 additions & 2 deletions api/layer/neofs.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ type NeoFS interface {
// extended ACL is modified within session if session token is not nil.
//
// It returns any error encountered which prevented the eACL from being saved.
SetContainerEACL(context.Context, eacl.Table, *session.Container, user.Signer) error
SetContainerEACL(context.Context, eacl.Table, *session.Container) error

// ContainerEACL reads the container eACL from NeoFS by the container ID.
//
Expand All @@ -168,7 +168,7 @@ type NeoFS interface {
// Successful return does not guarantee actual removal.
//
// It returns any error encountered which prevented the removal request from being sent.
DeleteContainer(context.Context, cid.ID, *session.Container, user.Signer) error
DeleteContainer(context.Context, cid.ID, *session.Container) error

// ReadObject reads a part of the object from the NeoFS container by identifier.
// Exact part is returned according to the parameters:
Expand Down
4 changes: 2 additions & 2 deletions api/layer/neofs_mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func (t *TestNeoFS) CreateContainer(_ context.Context, prm PrmContainerCreate) (
return id, nil
}

func (t *TestNeoFS) DeleteContainer(_ context.Context, cnrID cid.ID, _ *session.Container, _ user.Signer) error {
func (t *TestNeoFS) DeleteContainer(_ context.Context, cnrID cid.ID, _ *session.Container) error {
delete(t.containers, cnrID.EncodeToString())

return nil
Expand Down Expand Up @@ -257,7 +257,7 @@ func (t *TestNeoFS) AllObjects(cnrID cid.ID) []oid.ID {
return result
}

func (t *TestNeoFS) SetContainerEACL(_ context.Context, table eacl.Table, _ *session.Container, _ user.Signer) error {
func (t *TestNeoFS) SetContainerEACL(_ context.Context, table eacl.Table, _ *session.Container) error {
cnrID, ok := table.CID()
if !ok {
return errors.New("invalid cid")
Expand Down
8 changes: 4 additions & 4 deletions internal/neofs/neofs.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,14 +159,14 @@ func (x *NeoFS) UserContainers(ctx context.Context, id user.ID) ([]cid.ID, error
}

// SetContainerEACL implements neofs.NeoFS interface method.
func (x *NeoFS) SetContainerEACL(ctx context.Context, table eacl.Table, sessionToken *session.Container, signer user.Signer) error {
func (x *NeoFS) SetContainerEACL(ctx context.Context, table eacl.Table, sessionToken *session.Container) error {
var prm client.PrmContainerSetEACL
if sessionToken != nil {
prm.WithinSession(*sessionToken)
}

eaclWaiter := waiter.NewContainerSetEACLWaiter(x.pool, waiter.DefaultPollInterval)
err := eaclWaiter.ContainerSetEACL(ctx, table, signer, prm)
err := eaclWaiter.ContainerSetEACL(ctx, table, x.gateSigner, prm)
if err != nil {
return fmt.Errorf("save eACL via connection pool: %w", err)
}
Expand All @@ -186,14 +186,14 @@ func (x *NeoFS) ContainerEACL(ctx context.Context, id cid.ID) (*eacl.Table, erro
}

// DeleteContainer implements neofs.NeoFS interface method.
func (x *NeoFS) DeleteContainer(ctx context.Context, id cid.ID, token *session.Container, signer user.Signer) error {
func (x *NeoFS) DeleteContainer(ctx context.Context, id cid.ID, token *session.Container) error {
var prm client.PrmContainerDelete
if token != nil {
prm.WithinSession(*token)
}

deleteWaiter := waiter.NewContainerDeleteWaiter(x.pool, waiter.DefaultPollInterval)
err := deleteWaiter.ContainerDelete(ctx, id, signer, prm)
err := deleteWaiter.ContainerDelete(ctx, id, x.gateSigner, prm)
if err != nil {
return fmt.Errorf("delete container via connection pool: %w", err)
}
Expand Down

0 comments on commit 4a66ae8

Please sign in to comment.