From 9c737e7cdf7679f66dcb1a39685009c8b148b2f6 Mon Sep 17 00:00:00 2001 From: Ekaterina Lebedeva Date: Mon, 9 Sep 2024 13:45:56 +0300 Subject: [PATCH] [#1331] tree: Add order flag to `tree get-subtree` Added `--ordered` flag to sort output by ascending FileName. Signed-off-by: Ekaterina Lebedeva --- cmd/frostfs-cli/modules/container/list.go | 2 -- cmd/frostfs-cli/modules/tree/root.go | 1 + cmd/frostfs-cli/modules/tree/subtree.go | 11 +++++++++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/cmd/frostfs-cli/modules/container/list.go b/cmd/frostfs-cli/modules/container/list.go index 6d0019ec4..317d4bc31 100644 --- a/cmd/frostfs-cli/modules/container/list.go +++ b/cmd/frostfs-cli/modules/container/list.go @@ -86,8 +86,6 @@ var listContainersCmd = &cobra.Command{ if flagVarListPrintAttr { cnr.IterateAttributes(func(key, val string) { 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) } }) diff --git a/cmd/frostfs-cli/modules/tree/root.go b/cmd/frostfs-cli/modules/tree/root.go index efd1c08b5..5a53c50d6 100644 --- a/cmd/frostfs-cli/modules/tree/root.go +++ b/cmd/frostfs-cli/modules/tree/root.go @@ -49,6 +49,7 @@ const ( heightFlagKey = "height" countFlagKey = "count" depthFlagKey = "depth" + orderFlagKey = "ordered" ) func initCTID(cmd *cobra.Command) { diff --git a/cmd/frostfs-cli/modules/tree/subtree.go b/cmd/frostfs-cli/modules/tree/subtree.go index e58a13fd6..e88ef79cb 100644 --- a/cmd/frostfs-cli/modules/tree/subtree.go +++ b/cmd/frostfs-cli/modules/tree/subtree.go @@ -30,6 +30,7 @@ func initGetSubtreeCmd() { ff := getSubtreeCmd.Flags() ff.Uint64(rootIDFlagKey, 0, "Root ID to traverse from.") ff.Uint32(depthFlagKey, 10, "Traversal depth.") + ff.Bool(orderFlagKey, false, "Sort output by ascending FileName.") _ = getSubtreeCmd.MarkFlagRequired(commonflags.CIDFlag) _ = getSubtreeCmd.MarkFlagRequired(treeIDFlagKey) @@ -59,6 +60,13 @@ func getSubTree(cmd *cobra.Command, _ []string) { 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 if t := common.ReadBearerToken(cmd, bearerFlagKey); t != nil { bt = t.Marshal() @@ -71,6 +79,9 @@ func getSubTree(cmd *cobra.Command, _ []string) { RootId: []uint64{rid}, Depth: depth, BearerToken: bt, + OrderBy: &tree.GetSubTreeRequest_Body_Order{ + Direction: bodyOrder, + }, }, }