From 57619fbbe40a36b1ded6f7efb0960253dd6cd15d Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Thu, 13 Apr 2023 09:02:14 +0300 Subject: [PATCH] [#48] client: Refactor ContainerSetEACL() Signed-off-by: Evgenii Stratonikov --- client/container_set_eacl.go | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/client/container_set_eacl.go b/client/container_set_eacl.go index f3b76e70..5fea5fb9 100644 --- a/client/container_set_eacl.go +++ b/client/container_set_eacl.go @@ -9,6 +9,7 @@ import ( rpcapi "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/rpc" "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/rpc/client" v2session "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/session" + "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/signature" frostfscrypto "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/crypto" frostfsecdsa "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/crypto/ecdsa" "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/eacl" @@ -82,7 +83,7 @@ func (x *PrmContainerSetEACL) formRequest(c *Client) (*v2container.SetExtendedAC var req v2container.SetExtendedACLRequest req.SetBody(reqBody) - req.SetMetaHeader(&meta) + c.prepareRequest(&req, &meta) return &req, nil } @@ -115,24 +116,16 @@ func (c *Client) ContainerSetEACL(ctx context.Context, prm PrmContainerSetEACL) return nil, err } - // init call context - - var ( - cc contextCall - res ResContainerSetEACL - ) - - c.initCallContext(&cc) - cc.req = req - cc.statusRes = &res - cc.call = func() (responseV2, error) { - return rpcapi.SetEACL(&c.c, req, client.WithContext(ctx)) + if err := signature.SignServiceMessage(&c.prm.key, req); err != nil { + return nil, fmt.Errorf("sign request: %w", err) } - // process call - if !cc.processCall() { - return nil, cc.err + resp, err := rpcapi.SetEACL(&c.c, req, client.WithContext(ctx)) + if err != nil { + return nil, err } - return &res, nil + var res ResContainerSetEACL + res.st, err = c.processResponse(resp) + return &res, err }