From 8bc8f1f365b7d1a3d0408f47702fdd0d850a760d Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Thu, 13 Apr 2023 09:01:13 +0300 Subject: [PATCH] [#48] client: Refactor ContainerDelete() Signed-off-by: Evgenii Stratonikov --- client/container_delete.go | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/client/container_delete.go b/client/container_delete.go index 5e1fa51..3567bbe 100644 --- a/client/container_delete.go +++ b/client/container_delete.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" cid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id" frostfscrypto "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/crypto" frostfsecdsa "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/crypto/ecdsa" @@ -71,7 +72,7 @@ func (x *PrmContainerDelete) formRequest(c *Client) (*v2container.DeleteRequest, var req v2container.DeleteRequest req.SetBody(reqBody) - req.SetMetaHeader(&meta) + c.prepareRequest(&req, &meta) return &req, nil } @@ -118,24 +119,16 @@ func (c *Client) ContainerDelete(ctx context.Context, prm PrmContainerDelete) (* return nil, err } - // init call context - - var ( - cc contextCall - res ResContainerDelete - ) - - c.initCallContext(&cc) - cc.req = req - cc.statusRes = &res - cc.call = func() (responseV2, error) { - return rpcapi.DeleteContainer(&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.DeleteContainer(&c.c, req, client.WithContext(ctx)) + if err != nil { + return nil, err } - return &res, nil + var res ResContainerDelete + res.st, err = c.processResponse(resp) + return &res, err }