[#590] cli: fix SDK PrmContainerGet usage for GetContainerPrm
Signed-off-by: Airat Arifullin <a.arifullin@yadro.com>
This commit is contained in:
parent
c3c0574e3c
commit
6186329aec
6 changed files with 48 additions and 25 deletions
|
@ -103,13 +103,15 @@ func PutContainer(ctx context.Context, prm PutContainerPrm) (res PutContainerRes
|
||||||
|
|
||||||
// GetContainerPrm groups parameters of GetContainer operation.
|
// GetContainerPrm groups parameters of GetContainer operation.
|
||||||
type GetContainerPrm struct {
|
type GetContainerPrm struct {
|
||||||
commonPrm
|
Client *client.Client
|
||||||
cliPrm client.PrmContainerGet
|
ClientParams client.PrmContainerGet
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetContainer sets identifier of the container to be read.
|
// SetContainer sets identifier of the container to be read.
|
||||||
|
//
|
||||||
|
// Deprecated: Use GetContainerPrm.ClientParams.ContainerID instead.
|
||||||
func (x *GetContainerPrm) SetContainer(id cid.ID) {
|
func (x *GetContainerPrm) SetContainer(id cid.ID) {
|
||||||
*x.cliPrm.ContainerID = id
|
x.ClientParams.ContainerID = &id
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetContainerRes groups the resulting values of GetContainer operation.
|
// GetContainerRes groups the resulting values of GetContainer operation.
|
||||||
|
@ -126,7 +128,7 @@ func (x GetContainerRes) Container() containerSDK.Container {
|
||||||
//
|
//
|
||||||
// Returns any error which prevented the operation from completing correctly in error return.
|
// Returns any error which prevented the operation from completing correctly in error return.
|
||||||
func GetContainer(ctx context.Context, prm GetContainerPrm) (res GetContainerRes, err error) {
|
func GetContainer(ctx context.Context, prm GetContainerPrm) (res GetContainerRes, err error) {
|
||||||
res.cliRes, err = prm.cli.ContainerGet(ctx, prm.cliPrm)
|
res.cliRes, err = prm.Client.ContainerGet(ctx, prm.ClientParams)
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -134,9 +136,12 @@ func GetContainer(ctx context.Context, prm GetContainerPrm) (res GetContainerRes
|
||||||
// IsACLExtendable checks if ACL of the container referenced by the given identifier
|
// IsACLExtendable checks if ACL of the container referenced by the given identifier
|
||||||
// can be extended. Client connection MUST BE correctly established in advance.
|
// can be extended. Client connection MUST BE correctly established in advance.
|
||||||
func IsACLExtendable(ctx context.Context, c *client.Client, cnr cid.ID) (bool, error) {
|
func IsACLExtendable(ctx context.Context, c *client.Client, cnr cid.ID) (bool, error) {
|
||||||
var prm GetContainerPrm
|
prm := GetContainerPrm{
|
||||||
prm.SetClient(c)
|
Client: c,
|
||||||
prm.SetContainer(cnr)
|
ClientParams: client.PrmContainerGet{
|
||||||
|
ContainerID: &cnr,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
res, err := GetContainer(ctx, prm)
|
res, err := GetContainer(ctx, prm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -118,9 +118,12 @@ It will be stored in sidechain when inner ring will accepts it.`,
|
||||||
if containerAwait {
|
if containerAwait {
|
||||||
cmd.Println("awaiting...")
|
cmd.Println("awaiting...")
|
||||||
|
|
||||||
var getPrm internalclient.GetContainerPrm
|
getPrm := internalclient.GetContainerPrm{
|
||||||
getPrm.SetClient(cli)
|
Client: cli,
|
||||||
getPrm.SetContainer(id)
|
ClientParams: client.PrmContainerGet{
|
||||||
|
ContainerID: &id,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
for i := 0; i < awaitTimeout; i++ {
|
for i := 0; i < awaitTimeout; i++ {
|
||||||
time.Sleep(1 * time.Second)
|
time.Sleep(1 * time.Second)
|
||||||
|
|
|
@ -9,6 +9,7 @@ import (
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
||||||
commonCmd "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/internal/common"
|
commonCmd "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/internal/common"
|
||||||
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client"
|
||||||
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/user"
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/user"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
@ -30,9 +31,12 @@ Only owner of the container has a permission to remove container.`,
|
||||||
if force, _ := cmd.Flags().GetBool(commonflags.ForceFlag); !force {
|
if force, _ := cmd.Flags().GetBool(commonflags.ForceFlag); !force {
|
||||||
common.PrintVerbose(cmd, "Reading the container to check ownership...")
|
common.PrintVerbose(cmd, "Reading the container to check ownership...")
|
||||||
|
|
||||||
var getPrm internalclient.GetContainerPrm
|
getPrm := internalclient.GetContainerPrm{
|
||||||
getPrm.SetClient(cli)
|
Client: cli,
|
||||||
getPrm.SetContainer(id)
|
ClientParams: client.PrmContainerGet{
|
||||||
|
ContainerID: &id,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
resGet, err := internalclient.GetContainer(cmd.Context(), getPrm)
|
resGet, err := internalclient.GetContainer(cmd.Context(), getPrm)
|
||||||
commonCmd.ExitOnErr(cmd, "can't get the container: %w", err)
|
commonCmd.ExitOnErr(cmd, "can't get the container: %w", err)
|
||||||
|
@ -99,9 +103,12 @@ Only owner of the container has a permission to remove container.`,
|
||||||
if containerAwait {
|
if containerAwait {
|
||||||
cmd.Println("awaiting...")
|
cmd.Println("awaiting...")
|
||||||
|
|
||||||
var getPrm internalclient.GetContainerPrm
|
getPrm := internalclient.GetContainerPrm{
|
||||||
getPrm.SetClient(cli)
|
Client: cli,
|
||||||
getPrm.SetContainer(id)
|
ClientParams: client.PrmContainerGet{
|
||||||
|
ContainerID: &id,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
for i := 0; i < awaitTimeout; i++ {
|
for i := 0; i < awaitTimeout; i++ {
|
||||||
time.Sleep(1 * time.Second)
|
time.Sleep(1 * time.Second)
|
||||||
|
|
|
@ -10,6 +10,7 @@ import (
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-cli/modules/util"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-cli/modules/util"
|
||||||
commonCmd "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/internal/common"
|
commonCmd "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/internal/common"
|
||||||
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container"
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/acl"
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/acl"
|
||||||
cid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id"
|
cid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id"
|
||||||
|
@ -147,9 +148,12 @@ func getContainer(cmd *cobra.Command) (container.Container, *ecdsa.PrivateKey) {
|
||||||
pk = key.GetOrGenerate(cmd)
|
pk = key.GetOrGenerate(cmd)
|
||||||
cli := internalclient.GetSDKClientByFlag(cmd, pk, commonflags.RPC)
|
cli := internalclient.GetSDKClientByFlag(cmd, pk, commonflags.RPC)
|
||||||
|
|
||||||
var prm internalclient.GetContainerPrm
|
prm := internalclient.GetContainerPrm{
|
||||||
prm.SetClient(cli)
|
Client: cli,
|
||||||
prm.SetContainer(id)
|
ClientParams: client.PrmContainerGet{
|
||||||
|
ContainerID: &id,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
res, err := internalclient.GetContainer(cmd.Context(), prm)
|
res, err := internalclient.GetContainer(cmd.Context(), prm)
|
||||||
commonCmd.ExitOnErr(cmd, "rpc error: %w", err)
|
commonCmd.ExitOnErr(cmd, "rpc error: %w", err)
|
||||||
|
|
|
@ -52,8 +52,9 @@ var listContainersCmd = &cobra.Command{
|
||||||
res, err := internalclient.ListContainers(cmd.Context(), prm)
|
res, err := internalclient.ListContainers(cmd.Context(), prm)
|
||||||
commonCmd.ExitOnErr(cmd, "rpc error: %w", err)
|
commonCmd.ExitOnErr(cmd, "rpc error: %w", err)
|
||||||
|
|
||||||
var prmGet internalclient.GetContainerPrm
|
prmGet := internalclient.GetContainerPrm{
|
||||||
prmGet.SetClient(cli)
|
Client: cli,
|
||||||
|
}
|
||||||
|
|
||||||
containerIDs := res.IDList()
|
containerIDs := res.IDList()
|
||||||
for _, cnrID := range containerIDs {
|
for _, cnrID := range containerIDs {
|
||||||
|
@ -62,7 +63,7 @@ var listContainersCmd = &cobra.Command{
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
prmGet.SetContainer(cnrID)
|
prmGet.ClientParams.ContainerID = &cnrID
|
||||||
res, err := internalclient.GetContainer(cmd.Context(), prmGet)
|
res, err := internalclient.GetContainer(cmd.Context(), prmGet)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cmd.Printf(" failed to read attributes: %v\n", err)
|
cmd.Printf(" failed to read attributes: %v\n", err)
|
||||||
|
|
|
@ -155,9 +155,12 @@ func getPlacementPolicyAndNetmap(cmd *cobra.Command, cnrID cid.ID, cli *client.C
|
||||||
}
|
}
|
||||||
|
|
||||||
func getPlacementPolicy(ctx context.Context, cnrID cid.ID, cli *client.Client) (netmapSDK.PlacementPolicy, error) {
|
func getPlacementPolicy(ctx context.Context, cnrID cid.ID, cli *client.Client) (netmapSDK.PlacementPolicy, error) {
|
||||||
var prm internalclient.GetContainerPrm
|
prm := internalclient.GetContainerPrm{
|
||||||
prm.SetClient(cli)
|
Client: cli,
|
||||||
prm.SetContainer(cnrID)
|
ClientParams: client.PrmContainerGet{
|
||||||
|
ContainerID: &cnrID,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
res, err := internalclient.GetContainer(ctx, prm)
|
res, err := internalclient.GetContainer(ctx, prm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in a new issue