forked from TrueCloudLab/frostfs-node
[#1331] tree: Add order flag to tree get-subtree
Added `--ordered` flag to sort output by ascending FileName. Signed-off-by: Ekaterina Lebedeva <ekaterina.lebedeva@yadro.com>
This commit is contained in:
parent
d3b209c8e1
commit
9c737e7cdf
3 changed files with 12 additions and 2 deletions
|
@ -86,8 +86,6 @@ var listContainersCmd = &cobra.Command{
|
||||||
if flagVarListPrintAttr {
|
if flagVarListPrintAttr {
|
||||||
cnr.IterateAttributes(func(key, val string) {
|
cnr.IterateAttributes(func(key, val string) {
|
||||||
if !strings.HasPrefix(key, container.SysAttributePrefix) && !strings.HasPrefix(key, container.SysAttributePrefixNeoFS) {
|
if !strings.HasPrefix(key, container.SysAttributePrefix) && !strings.HasPrefix(key, container.SysAttributePrefixNeoFS) {
|
||||||
// FIXME(@cthulhu-rider): https://git.frostfs.info/TrueCloudLab/frostfs-sdk-go/issues/97
|
|
||||||
// Use dedicated method to skip system attributes.
|
|
||||||
cmd.Printf(" %s: %s\n", key, val)
|
cmd.Printf(" %s: %s\n", key, val)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -49,6 +49,7 @@ const (
|
||||||
heightFlagKey = "height"
|
heightFlagKey = "height"
|
||||||
countFlagKey = "count"
|
countFlagKey = "count"
|
||||||
depthFlagKey = "depth"
|
depthFlagKey = "depth"
|
||||||
|
orderFlagKey = "ordered"
|
||||||
)
|
)
|
||||||
|
|
||||||
func initCTID(cmd *cobra.Command) {
|
func initCTID(cmd *cobra.Command) {
|
||||||
|
|
|
@ -30,6 +30,7 @@ func initGetSubtreeCmd() {
|
||||||
ff := getSubtreeCmd.Flags()
|
ff := getSubtreeCmd.Flags()
|
||||||
ff.Uint64(rootIDFlagKey, 0, "Root ID to traverse from.")
|
ff.Uint64(rootIDFlagKey, 0, "Root ID to traverse from.")
|
||||||
ff.Uint32(depthFlagKey, 10, "Traversal depth.")
|
ff.Uint32(depthFlagKey, 10, "Traversal depth.")
|
||||||
|
ff.Bool(orderFlagKey, false, "Sort output by ascending FileName.")
|
||||||
|
|
||||||
_ = getSubtreeCmd.MarkFlagRequired(commonflags.CIDFlag)
|
_ = getSubtreeCmd.MarkFlagRequired(commonflags.CIDFlag)
|
||||||
_ = getSubtreeCmd.MarkFlagRequired(treeIDFlagKey)
|
_ = getSubtreeCmd.MarkFlagRequired(treeIDFlagKey)
|
||||||
|
@ -59,6 +60,13 @@ func getSubTree(cmd *cobra.Command, _ []string) {
|
||||||
|
|
||||||
depth, _ := cmd.Flags().GetUint32(depthFlagKey)
|
depth, _ := cmd.Flags().GetUint32(depthFlagKey)
|
||||||
|
|
||||||
|
order, _ := cmd.Flags().GetBool(orderFlagKey)
|
||||||
|
|
||||||
|
bodyOrder := tree.GetSubTreeRequest_Body_Order_None
|
||||||
|
if order {
|
||||||
|
bodyOrder = tree.GetSubTreeRequest_Body_Order_Asc
|
||||||
|
}
|
||||||
|
|
||||||
var bt []byte
|
var bt []byte
|
||||||
if t := common.ReadBearerToken(cmd, bearerFlagKey); t != nil {
|
if t := common.ReadBearerToken(cmd, bearerFlagKey); t != nil {
|
||||||
bt = t.Marshal()
|
bt = t.Marshal()
|
||||||
|
@ -71,6 +79,9 @@ func getSubTree(cmd *cobra.Command, _ []string) {
|
||||||
RootId: []uint64{rid},
|
RootId: []uint64{rid},
|
||||||
Depth: depth,
|
Depth: depth,
|
||||||
BearerToken: bt,
|
BearerToken: bt,
|
||||||
|
OrderBy: &tree.GetSubTreeRequest_Body_Order{
|
||||||
|
Direction: bodyOrder,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue