From 74c91eeef5fe520ae3f73a882315b1c9189ede53 Mon Sep 17 00:00:00 2001 From: aarifullin Date: Wed, 1 Nov 2023 18:18:28 +0300 Subject: [PATCH] [#777] client: Refactor PrmContainerList, PrmObjectSearch usage Signed-off-by: Airat Arifullin --- cmd/frostfs-cli/internal/client/client.go | 23 +++++----------- cmd/frostfs-cli/modules/container/list.go | 2 +- go.mod | 2 +- go.sum | Bin 327866 -> 327866 bytes pkg/services/object/internal/client/client.go | 26 +++++------------- 5 files changed, 16 insertions(+), 37 deletions(-) diff --git a/cmd/frostfs-cli/internal/client/client.go b/cmd/frostfs-cli/internal/client/client.go index b370ff3a..9807e111 100644 --- a/cmd/frostfs-cli/internal/client/client.go +++ b/cmd/frostfs-cli/internal/client/client.go @@ -689,24 +689,15 @@ func (x SearchObjectsRes) IDList() []oid.ID { // // Returns any error which prevented the operation from completing correctly in error return. func SearchObjects(ctx context.Context, prm SearchObjectsPrm) (*SearchObjectsRes, error) { - var cliPrm client.PrmObjectSearch - cliPrm.InContainer(prm.cnrID) - cliPrm.SetFilters(prm.filters) - - if prm.sessionToken != nil { - cliPrm.WithinSession(*prm.sessionToken) + cliPrm := client.PrmObjectSearch{ + XHeaders: prm.xHeaders, + Local: prm.local, + BearerToken: prm.bearerToken, + Session: prm.sessionToken, + ContainerID: &prm.cnrID, + Filters: prm.filters, } - if prm.bearerToken != nil { - cliPrm.WithBearerToken(*prm.bearerToken) - } - - if prm.local { - cliPrm.MarkLocal() - } - - cliPrm.WithXHeaders(prm.xHeaders...) - rdr, err := prm.cli.ObjectSearchInit(ctx, cliPrm) if err != nil { return nil, fmt.Errorf("init object search: %w", err) diff --git a/cmd/frostfs-cli/modules/container/list.go b/cmd/frostfs-cli/modules/container/list.go index 1c778776..1e7ba96e 100644 --- a/cmd/frostfs-cli/modules/container/list.go +++ b/cmd/frostfs-cli/modules/container/list.go @@ -47,7 +47,7 @@ var listContainersCmd = &cobra.Command{ var prm internalclient.ListContainersPrm prm.SetClient(cli) - prm.SetAccount(idUser) + prm.Account = &idUser res, err := internalclient.ListContainers(cmd.Context(), prm) commonCmd.ExitOnErr(cmd, "rpc error: %w", err) diff --git a/go.mod b/go.mod index 9e97238c..37cb477b 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( git.frostfs.info/TrueCloudLab/frostfs-api-go/v2 v2.16.1-0.20231031104748-498877e378fd git.frostfs.info/TrueCloudLab/frostfs-contract v0.18.1-0.20231102065436-9ed3845aa989 git.frostfs.info/TrueCloudLab/frostfs-observability v0.0.0-20230531082742-c97d21411eb6 - git.frostfs.info/TrueCloudLab/frostfs-sdk-go v0.0.0-20231027075445-a02c0bfac885 + git.frostfs.info/TrueCloudLab/frostfs-sdk-go v0.0.0-20231101144515-6fbe1595cb3d git.frostfs.info/TrueCloudLab/hrw v1.2.1 git.frostfs.info/TrueCloudLab/tzhash v1.8.0 github.com/cheggaaa/pb v1.0.29 diff --git a/go.sum b/go.sum index 80b6001674fe2693677d981072736a271722cedc..62fd85c8638b566b9ed6b79042ddaa1bf0600038 100644 GIT binary patch delta 127 zcmdnhD6*?jq+tu=9Bx-b14Ba-6H`M|U9+^LR6|os)8r)M6om{!EAKFmV!vY7{M3{{ zL+v!}RF^^v3r9EaY@gHs_q4pq^b(V#51Ho)?(O=YB%Cx1Y#y2X5MbZ I!_x5u0Ib3#ZvX%Q delta 127 zcmdnhD6*?jq+tu=9Bx+wBXa|DQxg+Y-9!VUWP_x%#AFK#Q-usetCA%D(DeL7KjYG3 zw~$ar%WN~FDoeA{K$jptuh7gY%aDpHuOdUol3=&|>51Ho)?(O=YB%Cx1Y#y2X5MbZ I!_x5u0J$9{asU7T diff --git a/pkg/services/object/internal/client/client.go b/pkg/services/object/internal/client/client.go index e0a7e562..dd2de0fd 100644 --- a/pkg/services/object/internal/client/client.go +++ b/pkg/services/object/internal/client/client.go @@ -474,12 +474,12 @@ type SearchObjectsPrm struct { // // Required parameter. func (x *SearchObjectsPrm) SetContainerID(id cid.ID) { - x.cliPrm.InContainer(id) + x.cliPrm.ContainerID = &id } // SetFilters sets search filters. func (x *SearchObjectsPrm) SetFilters(fs objectSDK.SearchFilters) { - x.cliPrm.SetFilters(fs) + x.cliPrm.Filters = fs } // SearchObjectsRes groups the resulting values of SearchObjects operation. @@ -496,23 +496,11 @@ func (x SearchObjectsRes) IDList() []oid.ID { // // Returns any error which prevented the operation from completing correctly in error return. func SearchObjects(ctx context.Context, prm SearchObjectsPrm) (*SearchObjectsRes, error) { - if prm.local { - prm.cliPrm.MarkLocal() - } - - if prm.tokenSession != nil { - prm.cliPrm.WithinSession(*prm.tokenSession) - } - - if prm.tokenBearer != nil { - prm.cliPrm.WithBearerToken(*prm.tokenBearer) - } - - prm.cliPrm.WithXHeaders(prm.xHeaders...) - - if prm.key != nil { - prm.cliPrm.UseKey(*prm.key) - } + prm.cliPrm.Local = prm.local + prm.cliPrm.Session = prm.tokenSession + prm.cliPrm.BearerToken = prm.tokenBearer + prm.cliPrm.XHeaders = prm.xHeaders + prm.cliPrm.Key = prm.key rdr, err := prm.cli.ObjectSearchInit(ctx, prm.cliPrm) if err != nil {