forked from TrueCloudLab/frostfs-node
[#406] cli: Pass context to internal client
Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
parent
63473d0806
commit
9562123c49
24 changed files with 83 additions and 82 deletions
|
@ -37,8 +37,8 @@ func (x BalanceOfRes) Balance() accounting.Decimal {
|
||||||
// BalanceOf requests the current balance of a FrostFS user.
|
// BalanceOf requests the current balance of a FrostFS user.
|
||||||
//
|
//
|
||||||
// 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 BalanceOf(prm BalanceOfPrm) (res BalanceOfRes, err error) {
|
func BalanceOf(ctx context.Context, prm BalanceOfPrm) (res BalanceOfRes, err error) {
|
||||||
res.cliRes, err = prm.cli.BalanceGet(context.Background(), prm.PrmBalanceGet)
|
res.cliRes, err = prm.cli.BalanceGet(ctx, prm.PrmBalanceGet)
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -62,8 +62,8 @@ func (x ListContainersRes) IDList() []cid.ID {
|
||||||
// ListContainers requests a list of FrostFS user's containers.
|
// ListContainers requests a list of FrostFS user's containers.
|
||||||
//
|
//
|
||||||
// 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 ListContainers(prm ListContainersPrm) (res ListContainersRes, err error) {
|
func ListContainers(ctx context.Context, prm ListContainersPrm) (res ListContainersRes, err error) {
|
||||||
res.cliRes, err = prm.cli.ContainerList(context.Background(), prm.PrmContainerList)
|
res.cliRes, err = prm.cli.ContainerList(ctx, prm.PrmContainerList)
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -92,8 +92,8 @@ func (x PutContainerRes) ID() cid.ID {
|
||||||
// Success can be verified by reading by identifier.
|
// Success can be verified by reading by identifier.
|
||||||
//
|
//
|
||||||
// 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 PutContainer(prm PutContainerPrm) (res PutContainerRes, err error) {
|
func PutContainer(ctx context.Context, prm PutContainerPrm) (res PutContainerRes, err error) {
|
||||||
cliRes, err := prm.cli.ContainerPut(context.Background(), prm.PrmContainerPut)
|
cliRes, err := prm.cli.ContainerPut(ctx, prm.PrmContainerPut)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
res.cnr = cliRes.ID()
|
res.cnr = cliRes.ID()
|
||||||
}
|
}
|
||||||
|
@ -125,20 +125,20 @@ func (x GetContainerRes) Container() containerSDK.Container {
|
||||||
// GetContainer reads a container from FrostFS by ID.
|
// GetContainer reads a container from FrostFS by ID.
|
||||||
//
|
//
|
||||||
// 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(prm GetContainerPrm) (res GetContainerRes, err error) {
|
func GetContainer(ctx context.Context, prm GetContainerPrm) (res GetContainerRes, err error) {
|
||||||
res.cliRes, err = prm.cli.ContainerGet(context.Background(), prm.cliPrm)
|
res.cliRes, err = prm.cli.ContainerGet(ctx, prm.cliPrm)
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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(c *client.Client, cnr cid.ID) (bool, error) {
|
func IsACLExtendable(ctx context.Context, c *client.Client, cnr cid.ID) (bool, error) {
|
||||||
var prm GetContainerPrm
|
var prm GetContainerPrm
|
||||||
prm.SetClient(c)
|
prm.SetClient(c)
|
||||||
prm.SetContainer(cnr)
|
prm.SetContainer(cnr)
|
||||||
|
|
||||||
res, err := GetContainer(prm)
|
res, err := GetContainer(ctx, prm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, fmt.Errorf("get container from the FrostFS: %w", err)
|
return false, fmt.Errorf("get container from the FrostFS: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -163,8 +163,8 @@ type DeleteContainerRes struct{}
|
||||||
// Success can be verified by reading by identifier.
|
// Success can be verified by reading by identifier.
|
||||||
//
|
//
|
||||||
// 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 DeleteContainer(prm DeleteContainerPrm) (res DeleteContainerRes, err error) {
|
func DeleteContainer(ctx context.Context, prm DeleteContainerPrm) (res DeleteContainerRes, err error) {
|
||||||
_, err = prm.cli.ContainerDelete(context.Background(), prm.PrmContainerDelete)
|
_, err = prm.cli.ContainerDelete(ctx, prm.PrmContainerDelete)
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -188,8 +188,8 @@ func (x EACLRes) EACL() eacl.Table {
|
||||||
// EACL reads eACL table from FrostFS by container ID.
|
// EACL reads eACL table from FrostFS by container ID.
|
||||||
//
|
//
|
||||||
// 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 EACL(prm EACLPrm) (res EACLRes, err error) {
|
func EACL(ctx context.Context, prm EACLPrm) (res EACLRes, err error) {
|
||||||
res.cliRes, err = prm.cli.ContainerEACL(context.Background(), prm.PrmContainerEACL)
|
res.cliRes, err = prm.cli.ContainerEACL(ctx, prm.PrmContainerEACL)
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -211,8 +211,8 @@ type SetEACLRes struct{}
|
||||||
// Success can be verified by reading by container identifier.
|
// Success can be verified by reading by container identifier.
|
||||||
//
|
//
|
||||||
// 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 SetEACL(prm SetEACLPrm) (res SetEACLRes, err error) {
|
func SetEACL(ctx context.Context, prm SetEACLPrm) (res SetEACLRes, err error) {
|
||||||
_, err = prm.cli.ContainerSetEACL(context.Background(), prm.PrmContainerSetEACL)
|
_, err = prm.cli.ContainerSetEACL(ctx, prm.PrmContainerSetEACL)
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -236,8 +236,8 @@ func (x NetworkInfoRes) NetworkInfo() netmap.NetworkInfo {
|
||||||
// NetworkInfo reads information about the FrostFS network.
|
// NetworkInfo reads information about the FrostFS network.
|
||||||
//
|
//
|
||||||
// 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 NetworkInfo(prm NetworkInfoPrm) (res NetworkInfoRes, err error) {
|
func NetworkInfo(ctx context.Context, prm NetworkInfoPrm) (res NetworkInfoRes, err error) {
|
||||||
res.cliRes, err = prm.cli.NetworkInfo(context.Background(), prm.PrmNetworkInfo)
|
res.cliRes, err = prm.cli.NetworkInfo(ctx, prm.PrmNetworkInfo)
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -266,8 +266,8 @@ func (x NodeInfoRes) LatestVersion() version.Version {
|
||||||
// NodeInfo requests information about the remote server from FrostFS netmap.
|
// NodeInfo requests information about the remote server from FrostFS netmap.
|
||||||
//
|
//
|
||||||
// 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 NodeInfo(prm NodeInfoPrm) (res NodeInfoRes, err error) {
|
func NodeInfo(ctx context.Context, prm NodeInfoPrm) (res NodeInfoRes, err error) {
|
||||||
res.cliRes, err = prm.cli.EndpointInfo(context.Background(), prm.PrmEndpointInfo)
|
res.cliRes, err = prm.cli.EndpointInfo(ctx, prm.PrmEndpointInfo)
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -290,8 +290,8 @@ func (x NetMapSnapshotRes) NetMap() netmap.NetMap {
|
||||||
// NetMapSnapshot requests current network view of the remote server.
|
// NetMapSnapshot requests current network view of the remote server.
|
||||||
//
|
//
|
||||||
// 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 NetMapSnapshot(prm NetMapSnapshotPrm) (res NetMapSnapshotRes, err error) {
|
func NetMapSnapshot(ctx context.Context, prm NetMapSnapshotPrm) (res NetMapSnapshotRes, err error) {
|
||||||
res.cliRes, err = prm.cli.NetMapSnapshot(context.Background(), client.PrmNetMapSnapshot{})
|
res.cliRes, err = prm.cli.NetMapSnapshot(ctx, client.PrmNetMapSnapshot{})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -319,8 +319,8 @@ func (x CreateSessionRes) SessionKey() []byte {
|
||||||
// CreateSession opens a new unlimited session with the remote node.
|
// CreateSession opens a new unlimited session with the remote node.
|
||||||
//
|
//
|
||||||
// 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 CreateSession(prm CreateSessionPrm) (res CreateSessionRes, err error) {
|
func CreateSession(ctx context.Context, prm CreateSessionPrm) (res CreateSessionRes, err error) {
|
||||||
res.cliRes, err = prm.cli.SessionCreate(context.Background(), prm.PrmSessionCreate)
|
res.cliRes, err = prm.cli.SessionCreate(ctx, prm.PrmSessionCreate)
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -373,7 +373,7 @@ func (x PutObjectRes) ID() oid.ID {
|
||||||
// PutObject saves the object in FrostFS network.
|
// PutObject saves the object in FrostFS network.
|
||||||
//
|
//
|
||||||
// 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 PutObject(prm PutObjectPrm) (*PutObjectRes, error) {
|
func PutObject(ctx context.Context, prm PutObjectPrm) (*PutObjectRes, error) {
|
||||||
var putPrm client.PrmObjectPutInit
|
var putPrm client.PrmObjectPutInit
|
||||||
|
|
||||||
if prm.sessionToken != nil {
|
if prm.sessionToken != nil {
|
||||||
|
@ -391,7 +391,7 @@ func PutObject(prm PutObjectPrm) (*PutObjectRes, error) {
|
||||||
putPrm.WithXHeaders(prm.xHeaders...)
|
putPrm.WithXHeaders(prm.xHeaders...)
|
||||||
putPrm.SetCopiesNumberByVectors(prm.copyNum)
|
putPrm.SetCopiesNumberByVectors(prm.copyNum)
|
||||||
|
|
||||||
wrt, err := prm.cli.ObjectPutInit(context.Background(), putPrm)
|
wrt, err := prm.cli.ObjectPutInit(ctx, putPrm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("init object writing: %w", err)
|
return nil, fmt.Errorf("init object writing: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -471,7 +471,7 @@ func (x DeleteObjectRes) Tombstone() oid.ID {
|
||||||
// DeleteObject marks an object to be removed from FrostFS through tombstone placement.
|
// DeleteObject marks an object to be removed from FrostFS through tombstone placement.
|
||||||
//
|
//
|
||||||
// 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 DeleteObject(prm DeleteObjectPrm) (*DeleteObjectRes, error) {
|
func DeleteObject(ctx context.Context, prm DeleteObjectPrm) (*DeleteObjectRes, error) {
|
||||||
var delPrm client.PrmObjectDelete
|
var delPrm client.PrmObjectDelete
|
||||||
delPrm.FromContainer(prm.objAddr.Container())
|
delPrm.FromContainer(prm.objAddr.Container())
|
||||||
delPrm.ByID(prm.objAddr.Object())
|
delPrm.ByID(prm.objAddr.Object())
|
||||||
|
@ -486,7 +486,7 @@ func DeleteObject(prm DeleteObjectPrm) (*DeleteObjectRes, error) {
|
||||||
|
|
||||||
delPrm.WithXHeaders(prm.xHeaders...)
|
delPrm.WithXHeaders(prm.xHeaders...)
|
||||||
|
|
||||||
cliRes, err := prm.cli.ObjectDelete(context.Background(), delPrm)
|
cliRes, err := prm.cli.ObjectDelete(ctx, delPrm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("remove object via client: %w", err)
|
return nil, fmt.Errorf("remove object via client: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -527,7 +527,7 @@ func (x GetObjectRes) Header() *object.Object {
|
||||||
//
|
//
|
||||||
// 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.
|
||||||
// For raw reading, returns *object.SplitInfoError error if object is virtual.
|
// For raw reading, returns *object.SplitInfoError error if object is virtual.
|
||||||
func GetObject(prm GetObjectPrm) (*GetObjectRes, error) {
|
func GetObject(ctx context.Context, prm GetObjectPrm) (*GetObjectRes, error) {
|
||||||
var getPrm client.PrmObjectGet
|
var getPrm client.PrmObjectGet
|
||||||
getPrm.FromContainer(prm.objAddr.Container())
|
getPrm.FromContainer(prm.objAddr.Container())
|
||||||
getPrm.ByID(prm.objAddr.Object())
|
getPrm.ByID(prm.objAddr.Object())
|
||||||
|
@ -550,7 +550,7 @@ func GetObject(prm GetObjectPrm) (*GetObjectRes, error) {
|
||||||
|
|
||||||
getPrm.WithXHeaders(prm.xHeaders...)
|
getPrm.WithXHeaders(prm.xHeaders...)
|
||||||
|
|
||||||
rdr, err := prm.cli.ObjectGetInit(context.Background(), getPrm)
|
rdr, err := prm.cli.ObjectGetInit(ctx, getPrm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("init object reading on client: %w", err)
|
return nil, fmt.Errorf("init object reading on client: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -603,7 +603,7 @@ func (x HeadObjectRes) Header() *object.Object {
|
||||||
//
|
//
|
||||||
// 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.
|
||||||
// For raw reading, returns *object.SplitInfoError error if object is virtual.
|
// For raw reading, returns *object.SplitInfoError error if object is virtual.
|
||||||
func HeadObject(prm HeadObjectPrm) (*HeadObjectRes, error) {
|
func HeadObject(ctx context.Context, prm HeadObjectPrm) (*HeadObjectRes, error) {
|
||||||
var cliPrm client.PrmObjectHead
|
var cliPrm client.PrmObjectHead
|
||||||
cliPrm.FromContainer(prm.objAddr.Container())
|
cliPrm.FromContainer(prm.objAddr.Container())
|
||||||
cliPrm.ByID(prm.objAddr.Object())
|
cliPrm.ByID(prm.objAddr.Object())
|
||||||
|
@ -626,7 +626,7 @@ func HeadObject(prm HeadObjectPrm) (*HeadObjectRes, error) {
|
||||||
|
|
||||||
cliPrm.WithXHeaders(prm.xHeaders...)
|
cliPrm.WithXHeaders(prm.xHeaders...)
|
||||||
|
|
||||||
res, err := prm.cli.ObjectHead(context.Background(), cliPrm)
|
res, err := prm.cli.ObjectHead(ctx, cliPrm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("read object header via client: %w", err)
|
return nil, fmt.Errorf("read object header via client: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -668,7 +668,7 @@ func (x SearchObjectsRes) IDList() []oid.ID {
|
||||||
// SearchObjects selects objects from the container which match the filters.
|
// SearchObjects selects objects from the container which match the filters.
|
||||||
//
|
//
|
||||||
// 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 SearchObjects(prm SearchObjectsPrm) (*SearchObjectsRes, error) {
|
func SearchObjects(ctx context.Context, prm SearchObjectsPrm) (*SearchObjectsRes, error) {
|
||||||
var cliPrm client.PrmObjectSearch
|
var cliPrm client.PrmObjectSearch
|
||||||
cliPrm.InContainer(prm.cnrID)
|
cliPrm.InContainer(prm.cnrID)
|
||||||
cliPrm.SetFilters(prm.filters)
|
cliPrm.SetFilters(prm.filters)
|
||||||
|
@ -687,7 +687,7 @@ func SearchObjects(prm SearchObjectsPrm) (*SearchObjectsRes, error) {
|
||||||
|
|
||||||
cliPrm.WithXHeaders(prm.xHeaders...)
|
cliPrm.WithXHeaders(prm.xHeaders...)
|
||||||
|
|
||||||
rdr, err := prm.cli.ObjectSearchInit(context.Background(), cliPrm)
|
rdr, err := prm.cli.ObjectSearchInit(ctx, cliPrm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("init object search: %w", err)
|
return nil, fmt.Errorf("init object search: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -758,7 +758,7 @@ func (x HashPayloadRangesRes) HashList() [][]byte {
|
||||||
//
|
//
|
||||||
// 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.
|
||||||
// Returns an error if number of received hashes differs with the number of requested ranges.
|
// Returns an error if number of received hashes differs with the number of requested ranges.
|
||||||
func HashPayloadRanges(prm HashPayloadRangesPrm) (*HashPayloadRangesRes, error) {
|
func HashPayloadRanges(ctx context.Context, prm HashPayloadRangesPrm) (*HashPayloadRangesRes, error) {
|
||||||
var cliPrm client.PrmObjectHash
|
var cliPrm client.PrmObjectHash
|
||||||
cliPrm.FromContainer(prm.objAddr.Container())
|
cliPrm.FromContainer(prm.objAddr.Container())
|
||||||
cliPrm.ByID(prm.objAddr.Object())
|
cliPrm.ByID(prm.objAddr.Object())
|
||||||
|
@ -792,7 +792,7 @@ func HashPayloadRanges(prm HashPayloadRangesPrm) (*HashPayloadRangesRes, error)
|
||||||
|
|
||||||
cliPrm.WithXHeaders(prm.xHeaders...)
|
cliPrm.WithXHeaders(prm.xHeaders...)
|
||||||
|
|
||||||
res, err := prm.cli.ObjectHash(context.Background(), cliPrm)
|
res, err := prm.cli.ObjectHash(ctx, cliPrm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("read payload hashes via client: %w", err)
|
return nil, fmt.Errorf("read payload hashes via client: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -826,7 +826,7 @@ type PayloadRangeRes struct{}
|
||||||
//
|
//
|
||||||
// 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.
|
||||||
// For raw reading, returns *object.SplitInfoError error if object is virtual.
|
// For raw reading, returns *object.SplitInfoError error if object is virtual.
|
||||||
func PayloadRange(prm PayloadRangePrm) (*PayloadRangeRes, error) {
|
func PayloadRange(ctx context.Context, prm PayloadRangePrm) (*PayloadRangeRes, error) {
|
||||||
var cliPrm client.PrmObjectRange
|
var cliPrm client.PrmObjectRange
|
||||||
cliPrm.FromContainer(prm.objAddr.Container())
|
cliPrm.FromContainer(prm.objAddr.Container())
|
||||||
cliPrm.ByID(prm.objAddr.Object())
|
cliPrm.ByID(prm.objAddr.Object())
|
||||||
|
@ -852,7 +852,7 @@ func PayloadRange(prm PayloadRangePrm) (*PayloadRangeRes, error) {
|
||||||
|
|
||||||
cliPrm.WithXHeaders(prm.xHeaders...)
|
cliPrm.WithXHeaders(prm.xHeaders...)
|
||||||
|
|
||||||
rdr, err := prm.cli.ObjectRangeInit(context.Background(), cliPrm)
|
rdr, err := prm.cli.ObjectRangeInit(ctx, cliPrm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("init payload reading: %w", err)
|
return nil, fmt.Errorf("init payload reading: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -886,12 +886,12 @@ type SyncContainerRes struct{}
|
||||||
// Interrupts on any writer error.
|
// Interrupts on any writer error.
|
||||||
//
|
//
|
||||||
// Panics if a container passed as a parameter is nil.
|
// Panics if a container passed as a parameter is nil.
|
||||||
func SyncContainerSettings(prm SyncContainerPrm) (*SyncContainerRes, error) {
|
func SyncContainerSettings(ctx context.Context, prm SyncContainerPrm) (*SyncContainerRes, error) {
|
||||||
if prm.c == nil {
|
if prm.c == nil {
|
||||||
panic("sync container settings with the network: nil container")
|
panic("sync container settings with the network: nil container")
|
||||||
}
|
}
|
||||||
|
|
||||||
err := client.SyncContainerWithNetwork(context.Background(), prm.c, prm.cli)
|
err := client.SyncContainerWithNetwork(ctx, prm.c, prm.cli)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@ var accountingBalanceCmd = &cobra.Command{
|
||||||
prm.SetClient(cli)
|
prm.SetClient(cli)
|
||||||
prm.SetAccount(idUser)
|
prm.SetAccount(idUser)
|
||||||
|
|
||||||
res, err := internalclient.BalanceOf(prm)
|
res, err := internalclient.BalanceOf(cmd.Context(), prm)
|
||||||
commonCmd.ExitOnErr(cmd, "rpc error: %w", err)
|
commonCmd.ExitOnErr(cmd, "rpc error: %w", err)
|
||||||
|
|
||||||
// print to stdout
|
// print to stdout
|
||||||
|
|
|
@ -48,7 +48,7 @@ It will be stored in sidechain when inner ring will accepts it.`,
|
||||||
var prm internalclient.NetMapSnapshotPrm
|
var prm internalclient.NetMapSnapshotPrm
|
||||||
prm.SetClient(cli)
|
prm.SetClient(cli)
|
||||||
|
|
||||||
resmap, err := internalclient.NetMapSnapshot(prm)
|
resmap, err := internalclient.NetMapSnapshot(cmd.Context(), prm)
|
||||||
commonCmd.ExitOnErr(cmd, "unable to get netmap snapshot to validate container placement, "+
|
commonCmd.ExitOnErr(cmd, "unable to get netmap snapshot to validate container placement, "+
|
||||||
"use --force option to skip this check: %w", err)
|
"use --force option to skip this check: %w", err)
|
||||||
|
|
||||||
|
@ -96,7 +96,7 @@ It will be stored in sidechain when inner ring will accepts it.`,
|
||||||
syncContainerPrm.SetClient(cli)
|
syncContainerPrm.SetClient(cli)
|
||||||
syncContainerPrm.SetContainer(&cnr)
|
syncContainerPrm.SetContainer(&cnr)
|
||||||
|
|
||||||
_, err = internalclient.SyncContainerSettings(syncContainerPrm)
|
_, err = internalclient.SyncContainerSettings(cmd.Context(), syncContainerPrm)
|
||||||
commonCmd.ExitOnErr(cmd, "syncing container's settings rpc error: %w", err)
|
commonCmd.ExitOnErr(cmd, "syncing container's settings rpc error: %w", err)
|
||||||
|
|
||||||
var putPrm internalclient.PutContainerPrm
|
var putPrm internalclient.PutContainerPrm
|
||||||
|
@ -107,7 +107,7 @@ It will be stored in sidechain when inner ring will accepts it.`,
|
||||||
putPrm.WithinSession(*tok)
|
putPrm.WithinSession(*tok)
|
||||||
}
|
}
|
||||||
|
|
||||||
res, err := internalclient.PutContainer(putPrm)
|
res, err := internalclient.PutContainer(cmd.Context(), putPrm)
|
||||||
commonCmd.ExitOnErr(cmd, "put container rpc error: %w", err)
|
commonCmd.ExitOnErr(cmd, "put container rpc error: %w", err)
|
||||||
|
|
||||||
id := res.ID()
|
id := res.ID()
|
||||||
|
@ -124,7 +124,7 @@ It will be stored in sidechain when inner ring will accepts it.`,
|
||||||
for i := 0; i < awaitTimeout; i++ {
|
for i := 0; i < awaitTimeout; i++ {
|
||||||
time.Sleep(1 * time.Second)
|
time.Sleep(1 * time.Second)
|
||||||
|
|
||||||
_, err := internalclient.GetContainer(getPrm)
|
_, err := internalclient.GetContainer(cmd.Context(), getPrm)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
cmd.Println("container has been persisted on sidechain")
|
cmd.Println("container has been persisted on sidechain")
|
||||||
return
|
return
|
||||||
|
|
|
@ -34,7 +34,7 @@ Only owner of the container has a permission to remove container.`,
|
||||||
getPrm.SetClient(cli)
|
getPrm.SetClient(cli)
|
||||||
getPrm.SetContainer(id)
|
getPrm.SetContainer(id)
|
||||||
|
|
||||||
resGet, err := internalclient.GetContainer(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)
|
||||||
|
|
||||||
owner := resGet.Container().Owner()
|
owner := resGet.Container().Owner()
|
||||||
|
@ -72,7 +72,7 @@ Only owner of the container has a permission to remove container.`,
|
||||||
|
|
||||||
common.PrintVerbose(cmd, "Searching for LOCK objects...")
|
common.PrintVerbose(cmd, "Searching for LOCK objects...")
|
||||||
|
|
||||||
res, err := internalclient.SearchObjects(searchPrm)
|
res, err := internalclient.SearchObjects(cmd.Context(), searchPrm)
|
||||||
commonCmd.ExitOnErr(cmd, "can't search for LOCK objects: %w", err)
|
commonCmd.ExitOnErr(cmd, "can't search for LOCK objects: %w", err)
|
||||||
|
|
||||||
if len(res.IDList()) != 0 {
|
if len(res.IDList()) != 0 {
|
||||||
|
@ -91,7 +91,7 @@ Only owner of the container has a permission to remove container.`,
|
||||||
delPrm.WithinSession(*tok)
|
delPrm.WithinSession(*tok)
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err := internalclient.DeleteContainer(delPrm)
|
_, err := internalclient.DeleteContainer(cmd.Context(), delPrm)
|
||||||
commonCmd.ExitOnErr(cmd, "rpc error: %w", err)
|
commonCmd.ExitOnErr(cmd, "rpc error: %w", err)
|
||||||
|
|
||||||
cmd.Println("container delete method invoked")
|
cmd.Println("container delete method invoked")
|
||||||
|
@ -106,7 +106,7 @@ Only owner of the container has a permission to remove container.`,
|
||||||
for i := 0; i < awaitTimeout; i++ {
|
for i := 0; i < awaitTimeout; i++ {
|
||||||
time.Sleep(1 * time.Second)
|
time.Sleep(1 * time.Second)
|
||||||
|
|
||||||
_, err := internalclient.GetContainer(getPrm)
|
_, err := internalclient.GetContainer(cmd.Context(), getPrm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cmd.Println("container has been removed:", containerID)
|
cmd.Println("container has been removed:", containerID)
|
||||||
return
|
return
|
||||||
|
|
|
@ -151,7 +151,7 @@ func getContainer(cmd *cobra.Command) (container.Container, *ecdsa.PrivateKey) {
|
||||||
prm.SetClient(cli)
|
prm.SetClient(cli)
|
||||||
prm.SetContainer(id)
|
prm.SetContainer(id)
|
||||||
|
|
||||||
res, err := internalclient.GetContainer(prm)
|
res, err := internalclient.GetContainer(cmd.Context(), prm)
|
||||||
commonCmd.ExitOnErr(cmd, "rpc error: %w", err)
|
commonCmd.ExitOnErr(cmd, "rpc error: %w", err)
|
||||||
|
|
||||||
cnr = res.Container()
|
cnr = res.Container()
|
||||||
|
|
|
@ -24,7 +24,7 @@ var getExtendedACLCmd = &cobra.Command{
|
||||||
eaclPrm.SetClient(cli)
|
eaclPrm.SetClient(cli)
|
||||||
eaclPrm.SetContainer(id)
|
eaclPrm.SetContainer(id)
|
||||||
|
|
||||||
res, err := internalclient.EACL(eaclPrm)
|
res, err := internalclient.EACL(cmd.Context(), eaclPrm)
|
||||||
commonCmd.ExitOnErr(cmd, "rpc error: %w", err)
|
commonCmd.ExitOnErr(cmd, "rpc error: %w", err)
|
||||||
|
|
||||||
eaclTable := res.EACL()
|
eaclTable := res.EACL()
|
||||||
|
|
|
@ -49,7 +49,7 @@ var listContainersCmd = &cobra.Command{
|
||||||
prm.SetClient(cli)
|
prm.SetClient(cli)
|
||||||
prm.SetAccount(idUser)
|
prm.SetAccount(idUser)
|
||||||
|
|
||||||
res, err := internalclient.ListContainers(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
|
var prmGet internalclient.GetContainerPrm
|
||||||
|
@ -63,7 +63,7 @@ var listContainersCmd = &cobra.Command{
|
||||||
}
|
}
|
||||||
|
|
||||||
prmGet.SetContainer(cnrID)
|
prmGet.SetContainer(cnrID)
|
||||||
res, err := internalclient.GetContainer(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)
|
||||||
continue
|
continue
|
||||||
|
|
|
@ -51,7 +51,7 @@ var listContainerObjectsCmd = &cobra.Command{
|
||||||
prmSearch.SetContainerID(id)
|
prmSearch.SetContainerID(id)
|
||||||
prmSearch.SetFilters(*filters)
|
prmSearch.SetFilters(*filters)
|
||||||
|
|
||||||
res, err := internalclient.SearchObjects(prmSearch)
|
res, err := internalclient.SearchObjects(cmd.Context(), prmSearch)
|
||||||
commonCmd.ExitOnErr(cmd, "rpc error: %w", err)
|
commonCmd.ExitOnErr(cmd, "rpc error: %w", err)
|
||||||
|
|
||||||
objectIDs := res.IDList()
|
objectIDs := res.IDList()
|
||||||
|
@ -65,7 +65,7 @@ var listContainerObjectsCmd = &cobra.Command{
|
||||||
addr.SetObject(objectIDs[i])
|
addr.SetObject(objectIDs[i])
|
||||||
prmHead.SetAddress(addr)
|
prmHead.SetAddress(addr)
|
||||||
|
|
||||||
resHead, err := internalclient.HeadObject(prmHead)
|
resHead, err := internalclient.HeadObject(cmd.Context(), prmHead)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
attrs := resHead.Header().Attributes()
|
attrs := resHead.Header().Attributes()
|
||||||
for i := range attrs {
|
for i := range attrs {
|
||||||
|
|
|
@ -31,7 +31,7 @@ var containerNodesCmd = &cobra.Command{
|
||||||
var prm internalclient.NetMapSnapshotPrm
|
var prm internalclient.NetMapSnapshotPrm
|
||||||
prm.SetClient(cli)
|
prm.SetClient(cli)
|
||||||
|
|
||||||
resmap, err := internalclient.NetMapSnapshot(prm)
|
resmap, err := internalclient.NetMapSnapshot(cmd.Context(), prm)
|
||||||
commonCmd.ExitOnErr(cmd, "unable to get netmap snapshot", err)
|
commonCmd.ExitOnErr(cmd, "unable to get netmap snapshot", err)
|
||||||
|
|
||||||
var id cid.ID
|
var id cid.ID
|
||||||
|
|
|
@ -38,7 +38,7 @@ Container ID in EACL table will be substituted with ID from the CLI.`,
|
||||||
if !flagVarsSetEACL.noPreCheck {
|
if !flagVarsSetEACL.noPreCheck {
|
||||||
cmd.Println("Checking the ability to modify access rights in the container...")
|
cmd.Println("Checking the ability to modify access rights in the container...")
|
||||||
|
|
||||||
extendable, err := internalclient.IsACLExtendable(cli, id)
|
extendable, err := internalclient.IsACLExtendable(cmd.Context(), cli, id)
|
||||||
commonCmd.ExitOnErr(cmd, "Extensibility check failure: %w", err)
|
commonCmd.ExitOnErr(cmd, "Extensibility check failure: %w", err)
|
||||||
|
|
||||||
if !extendable {
|
if !extendable {
|
||||||
|
@ -56,7 +56,7 @@ Container ID in EACL table will be substituted with ID from the CLI.`,
|
||||||
setEACLPrm.WithinSession(*tok)
|
setEACLPrm.WithinSession(*tok)
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err := internalclient.SetEACL(setEACLPrm)
|
_, err := internalclient.SetEACL(cmd.Context(), setEACLPrm)
|
||||||
commonCmd.ExitOnErr(cmd, "rpc error: %w", err)
|
commonCmd.ExitOnErr(cmd, "rpc error: %w", err)
|
||||||
|
|
||||||
if containerAwait {
|
if containerAwait {
|
||||||
|
@ -72,7 +72,7 @@ Container ID in EACL table will be substituted with ID from the CLI.`,
|
||||||
for i := 0; i < awaitTimeout; i++ {
|
for i := 0; i < awaitTimeout; i++ {
|
||||||
time.Sleep(1 * time.Second)
|
time.Sleep(1 * time.Second)
|
||||||
|
|
||||||
res, err := internalclient.EACL(getEACLPrm)
|
res, err := internalclient.EACL(cmd.Context(), getEACLPrm)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
// compare binary values because EACL could have been set already
|
// compare binary values because EACL could have been set already
|
||||||
table := res.EACL()
|
table := res.EACL()
|
||||||
|
|
|
@ -19,7 +19,7 @@ var getEpochCmd = &cobra.Command{
|
||||||
var prm internalclient.NetworkInfoPrm
|
var prm internalclient.NetworkInfoPrm
|
||||||
prm.SetClient(cli)
|
prm.SetClient(cli)
|
||||||
|
|
||||||
res, err := internalclient.NetworkInfo(prm)
|
res, err := internalclient.NetworkInfo(cmd.Context(), prm)
|
||||||
commonCmd.ExitOnErr(cmd, "rpc error: %w", err)
|
commonCmd.ExitOnErr(cmd, "rpc error: %w", err)
|
||||||
|
|
||||||
netInfo := res.NetworkInfo()
|
netInfo := res.NetworkInfo()
|
||||||
|
|
|
@ -23,7 +23,7 @@ var netInfoCmd = &cobra.Command{
|
||||||
var prm internalclient.NetworkInfoPrm
|
var prm internalclient.NetworkInfoPrm
|
||||||
prm.SetClient(cli)
|
prm.SetClient(cli)
|
||||||
|
|
||||||
res, err := internalclient.NetworkInfo(prm)
|
res, err := internalclient.NetworkInfo(cmd.Context(), prm)
|
||||||
commonCmd.ExitOnErr(cmd, "rpc error: %w", err)
|
commonCmd.ExitOnErr(cmd, "rpc error: %w", err)
|
||||||
|
|
||||||
netInfo := res.NetworkInfo()
|
netInfo := res.NetworkInfo()
|
||||||
|
|
|
@ -25,7 +25,7 @@ var nodeInfoCmd = &cobra.Command{
|
||||||
var prm internalclient.NodeInfoPrm
|
var prm internalclient.NodeInfoPrm
|
||||||
prm.SetClient(cli)
|
prm.SetClient(cli)
|
||||||
|
|
||||||
res, err := internalclient.NodeInfo(prm)
|
res, err := internalclient.NodeInfo(cmd.Context(), prm)
|
||||||
commonCmd.ExitOnErr(cmd, "rpc error: %w", err)
|
commonCmd.ExitOnErr(cmd, "rpc error: %w", err)
|
||||||
|
|
||||||
prettyPrintNodeInfo(cmd, res.NodeInfo())
|
prettyPrintNodeInfo(cmd, res.NodeInfo())
|
||||||
|
|
|
@ -19,7 +19,7 @@ var snapshotCmd = &cobra.Command{
|
||||||
var prm internalclient.NetMapSnapshotPrm
|
var prm internalclient.NetMapSnapshotPrm
|
||||||
prm.SetClient(cli)
|
prm.SetClient(cli)
|
||||||
|
|
||||||
res, err := internalclient.NetMapSnapshot(prm)
|
res, err := internalclient.NetMapSnapshot(cmd.Context(), prm)
|
||||||
commonCmd.ExitOnErr(cmd, "rpc error: %w", err)
|
commonCmd.ExitOnErr(cmd, "rpc error: %w", err)
|
||||||
|
|
||||||
commonCmd.PrettyPrintNetMap(cmd, res.NetMap(), false)
|
commonCmd.PrettyPrintNetMap(cmd, res.NetMap(), false)
|
||||||
|
|
|
@ -65,7 +65,7 @@ func deleteObject(cmd *cobra.Command, _ []string) {
|
||||||
Prepare(cmd, &prm)
|
Prepare(cmd, &prm)
|
||||||
prm.SetAddress(objAddr)
|
prm.SetAddress(objAddr)
|
||||||
|
|
||||||
res, err := internalclient.DeleteObject(prm)
|
res, err := internalclient.DeleteObject(cmd.Context(), prm)
|
||||||
commonCmd.ExitOnErr(cmd, "rpc error: %w", err)
|
commonCmd.ExitOnErr(cmd, "rpc error: %w", err)
|
||||||
|
|
||||||
tomb := res.Tombstone()
|
tomb := res.Tombstone()
|
||||||
|
|
|
@ -90,7 +90,7 @@ func getObject(cmd *cobra.Command, _ []string) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
res, err := internalclient.GetObject(prm)
|
res, err := internalclient.GetObject(cmd.Context(), prm)
|
||||||
if p != nil {
|
if p != nil {
|
||||||
p.Finish()
|
p.Finish()
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,7 +75,7 @@ func getObjectHash(cmd *cobra.Command, _ []string) {
|
||||||
headPrm.SetAddress(objAddr)
|
headPrm.SetAddress(objAddr)
|
||||||
|
|
||||||
// get hash of full payload through HEAD (may be user can do it through dedicated command?)
|
// get hash of full payload through HEAD (may be user can do it through dedicated command?)
|
||||||
res, err := internalclient.HeadObject(headPrm)
|
res, err := internalclient.HeadObject(cmd.Context(), headPrm)
|
||||||
commonCmd.ExitOnErr(cmd, "rpc error: %w", err)
|
commonCmd.ExitOnErr(cmd, "rpc error: %w", err)
|
||||||
|
|
||||||
var cs checksum.Checksum
|
var cs checksum.Checksum
|
||||||
|
@ -108,7 +108,7 @@ func getObjectHash(cmd *cobra.Command, _ []string) {
|
||||||
hashPrm.TZ()
|
hashPrm.TZ()
|
||||||
}
|
}
|
||||||
|
|
||||||
res, err := internalclient.HashPayloadRanges(hashPrm)
|
res, err := internalclient.HashPayloadRanges(cmd.Context(), hashPrm)
|
||||||
commonCmd.ExitOnErr(cmd, "rpc error: %w", err)
|
commonCmd.ExitOnErr(cmd, "rpc error: %w", err)
|
||||||
|
|
||||||
hs := res.HashList()
|
hs := res.HashList()
|
||||||
|
|
|
@ -64,7 +64,7 @@ func getObjectHeader(cmd *cobra.Command, _ []string) {
|
||||||
prm.SetAddress(objAddr)
|
prm.SetAddress(objAddr)
|
||||||
prm.SetMainOnlyFlag(mainOnly)
|
prm.SetMainOnlyFlag(mainOnly)
|
||||||
|
|
||||||
res, err := internalclient.HeadObject(prm)
|
res, err := internalclient.HeadObject(cmd.Context(), prm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if ok := printSplitInfoErr(cmd, err); ok {
|
if ok := printSplitInfoErr(cmd, err); ok {
|
||||||
return
|
return
|
||||||
|
|
|
@ -104,7 +104,7 @@ var objectLockCmd = &cobra.Command{
|
||||||
Prepare(cmd, &prm)
|
Prepare(cmd, &prm)
|
||||||
prm.SetHeader(obj)
|
prm.SetHeader(obj)
|
||||||
|
|
||||||
res, err := internalclient.PutObject(prm)
|
res, err := internalclient.PutObject(cmd.Context(), prm)
|
||||||
commonCmd.ExitOnErr(cmd, "Store lock object in FrostFS: %w", err)
|
commonCmd.ExitOnErr(cmd, "Store lock object in FrostFS: %w", err)
|
||||||
|
|
||||||
cmd.Printf("Lock object ID: %s\n", res.ID())
|
cmd.Printf("Lock object ID: %s\n", res.ID())
|
||||||
|
|
|
@ -131,7 +131,7 @@ func putObject(cmd *cobra.Command, _ []string) {
|
||||||
prm.SetCopiesNumberByVectors(cn)
|
prm.SetCopiesNumberByVectors(cn)
|
||||||
}
|
}
|
||||||
|
|
||||||
res, err := internalclient.PutObject(prm)
|
res, err := internalclient.PutObject(cmd.Context(), prm)
|
||||||
if p != nil {
|
if p != nil {
|
||||||
p.Finish()
|
p.Finish()
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,7 +87,7 @@ func getObjectRange(cmd *cobra.Command, _ []string) {
|
||||||
prm.SetRange(ranges[0])
|
prm.SetRange(ranges[0])
|
||||||
prm.SetPayloadWriter(out)
|
prm.SetPayloadWriter(out)
|
||||||
|
|
||||||
_, err = internalclient.PayloadRange(prm)
|
_, err = internalclient.PayloadRange(cmd.Context(), prm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if ok := printSplitInfoErr(cmd, err); ok {
|
if ok := printSplitInfoErr(cmd, err); ok {
|
||||||
return
|
return
|
||||||
|
|
|
@ -61,7 +61,7 @@ func searchObject(cmd *cobra.Command, _ []string) {
|
||||||
prm.SetContainerID(cnr)
|
prm.SetContainerID(cnr)
|
||||||
prm.SetFilters(sf)
|
prm.SetFilters(sf)
|
||||||
|
|
||||||
res, err := internalclient.SearchObjects(prm)
|
res, err := internalclient.SearchObjects(cmd.Context(), prm)
|
||||||
commonCmd.ExitOnErr(cmd, "rpc error: %w", err)
|
commonCmd.ExitOnErr(cmd, "rpc error: %w", err)
|
||||||
|
|
||||||
ids := res.IDList()
|
ids := res.IDList()
|
||||||
|
|
|
@ -278,7 +278,7 @@ func OpenSessionViaClient(cmd *cobra.Command, dst SessionPrm, cli *client.Client
|
||||||
|
|
||||||
common.PrintVerbose(cmd, "Opening remote session with the node...")
|
common.PrintVerbose(cmd, "Opening remote session with the node...")
|
||||||
|
|
||||||
err := sessionCli.CreateSession(&tok, cli, sessionLifetime)
|
err := sessionCli.CreateSession(cmd.Context(), &tok, cli, sessionLifetime)
|
||||||
commonCmd.ExitOnErr(cmd, "open remote session: %w", err)
|
commonCmd.ExitOnErr(cmd, "open remote session: %w", err)
|
||||||
|
|
||||||
common.PrintVerbose(cmd, "Session successfully opened.")
|
common.PrintVerbose(cmd, "Session successfully opened.")
|
||||||
|
@ -354,7 +354,7 @@ func collectObjectRelatives(cmd *cobra.Command, cli *client.Client, cnr cid.ID,
|
||||||
|
|
||||||
Prepare(cmd, &prmHead)
|
Prepare(cmd, &prmHead)
|
||||||
|
|
||||||
_, err := internal.HeadObject(prmHead)
|
_, err := internal.HeadObject(cmd.Context(), prmHead)
|
||||||
|
|
||||||
var errSplit *object.SplitInfoError
|
var errSplit *object.SplitInfoError
|
||||||
|
|
||||||
|
@ -396,7 +396,7 @@ func tryGetSplitMembersByLinkingObject(cmd *cobra.Command, splitInfo *object.Spl
|
||||||
prmHead.SetRawFlag(false)
|
prmHead.SetRawFlag(false)
|
||||||
// client is already set
|
// client is already set
|
||||||
|
|
||||||
res, err := internal.HeadObject(prmHead)
|
res, err := internal.HeadObject(cmd.Context(), prmHead)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
children := res.Header().Children()
|
children := res.Header().Children()
|
||||||
|
|
||||||
|
@ -425,7 +425,7 @@ func tryGetSplitMembersBySplitID(cmd *cobra.Command, splitInfo *object.SplitInfo
|
||||||
prm.SetClient(cli)
|
prm.SetClient(cli)
|
||||||
prm.SetFilters(query)
|
prm.SetFilters(query)
|
||||||
|
|
||||||
res, err := internal.SearchObjects(prm)
|
res, err := internal.SearchObjects(cmd.Context(), prm)
|
||||||
commonCmd.ExitOnErr(cmd, "failed to search objects by split ID: %w", err)
|
commonCmd.ExitOnErr(cmd, "failed to search objects by split ID: %w", err)
|
||||||
|
|
||||||
parts := res.IDList()
|
parts := res.IDList()
|
||||||
|
@ -463,7 +463,7 @@ func tryRestoreChainInReverse(cmd *cobra.Command, splitInfo *object.SplitInfo, p
|
||||||
addrObj.SetObject(idMember)
|
addrObj.SetObject(idMember)
|
||||||
prmHead.SetAddress(addrObj)
|
prmHead.SetAddress(addrObj)
|
||||||
|
|
||||||
res, err = internal.HeadObject(prmHead)
|
res, err = internal.HeadObject(cmd.Context(), prmHead)
|
||||||
commonCmd.ExitOnErr(cmd, "failed to read split chain member's header: %w", err)
|
commonCmd.ExitOnErr(cmd, "failed to read split chain member's header: %w", err)
|
||||||
|
|
||||||
idMember, ok = res.Header().PreviousID()
|
idMember, ok = res.Header().PreviousID()
|
||||||
|
@ -490,7 +490,7 @@ func tryRestoreChainInReverse(cmd *cobra.Command, splitInfo *object.SplitInfo, p
|
||||||
prmSearch.SetContainerID(cnr)
|
prmSearch.SetContainerID(cnr)
|
||||||
prmSearch.SetFilters(query)
|
prmSearch.SetFilters(query)
|
||||||
|
|
||||||
resSearch, err := internal.SearchObjects(prmSearch)
|
resSearch, err := internal.SearchObjects(cmd.Context(), prmSearch)
|
||||||
commonCmd.ExitOnErr(cmd, "failed to find object children: %w", err)
|
commonCmd.ExitOnErr(cmd, "failed to find object children: %w", err)
|
||||||
|
|
||||||
list := resSearch.IDList()
|
list := resSearch.IDList()
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package session
|
package session
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
|
@ -64,7 +65,7 @@ func createSession(cmd *cobra.Command, _ []string) {
|
||||||
|
|
||||||
var tok session.Object
|
var tok session.Object
|
||||||
|
|
||||||
err = CreateSession(&tok, c, lifetime)
|
err = CreateSession(cmd.Context(), &tok, c, lifetime)
|
||||||
commonCmd.ExitOnErr(cmd, "can't create session: %w", err)
|
commonCmd.ExitOnErr(cmd, "can't create session: %w", err)
|
||||||
|
|
||||||
var data []byte
|
var data []byte
|
||||||
|
@ -86,11 +87,11 @@ func createSession(cmd *cobra.Command, _ []string) {
|
||||||
// number of epochs.
|
// number of epochs.
|
||||||
//
|
//
|
||||||
// Fills ID, lifetime and session key.
|
// Fills ID, lifetime and session key.
|
||||||
func CreateSession(dst *session.Object, c *client.Client, lifetime uint64) error {
|
func CreateSession(ctx context.Context, dst *session.Object, c *client.Client, lifetime uint64) error {
|
||||||
var netInfoPrm internalclient.NetworkInfoPrm
|
var netInfoPrm internalclient.NetworkInfoPrm
|
||||||
netInfoPrm.SetClient(c)
|
netInfoPrm.SetClient(c)
|
||||||
|
|
||||||
ni, err := internalclient.NetworkInfo(netInfoPrm)
|
ni, err := internalclient.NetworkInfo(ctx, netInfoPrm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("can't fetch network info: %w", err)
|
return fmt.Errorf("can't fetch network info: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -102,7 +103,7 @@ func CreateSession(dst *session.Object, c *client.Client, lifetime uint64) error
|
||||||
sessionPrm.SetClient(c)
|
sessionPrm.SetClient(c)
|
||||||
sessionPrm.SetExp(exp)
|
sessionPrm.SetExp(exp)
|
||||||
|
|
||||||
sessionRes, err := internalclient.CreateSession(sessionPrm)
|
sessionRes, err := internalclient.CreateSession(ctx, sessionPrm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("can't open session: %w", err)
|
return fmt.Errorf("can't open session: %w", err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue