From 25de451a2f7e32aec008d7a523673f45cb9bf9be Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Mon, 24 May 2021 21:51:22 +0300 Subject: [PATCH] [#283] client/container: Write new fields to eACL table in GetEACL Call `SetSessionToken` and `SetSignature` methods on resulting eACL table with items from response body. From now eACL signature can be accessed from the table itself, so `EACLWithSignature.Signature` is marked deprecated. Signed-off-by: Leonard Lyubich --- pkg/client/container.go | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/pkg/client/container.go b/pkg/client/container.go index 7e3a25e..66cf3f4 100644 --- a/pkg/client/container.go +++ b/pkg/client/container.go @@ -49,8 +49,6 @@ type delContainerSignWrapper struct { // EACLWithSignature represents eACL table/signature pair. type EACLWithSignature struct { table *eacl.Table - - sig *pkg.Signature } func (c delContainerSignWrapper) ReadSignedData(bytes []byte) ([]byte, error) { @@ -67,8 +65,10 @@ func (e EACLWithSignature) EACL() *eacl.Table { } // Signature returns table signature. +// +// Deprecated: use EACL().Signature() instead. func (e EACLWithSignature) Signature() *pkg.Signature { - return e.sig + return e.table.Signature() } func (c *clientImpl) PutContainer(ctx context.Context, cnr *container.Container, opts ...CallOption) (*container.ID, error) { @@ -333,9 +333,18 @@ func (c *clientImpl) GetEACL(ctx context.Context, id *container.ID, opts ...Call body := resp.GetBody() + table := eacl.NewTableFromV2(body.GetEACL()) + + table.SetSessionToken( + session.NewTokenFromV2(body.GetSessionToken()), + ) + + table.SetSignature( + pkg.NewSignatureFromV2(body.GetSignature()), + ) + return &EACLWithSignature{ - table: eacl.NewTableFromV2(body.GetEACL()), - sig: pkg.NewSignatureFromV2(body.GetSignature()), + table: table, }, nil }