Request: Non Recursive "directory" listing

Open
#100 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
30/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
go

Research direction

Start with the existing List(key) entry point and trace how the library's backends enumerate keys under a prefix. Resolve the API design between recursion or depth and child-type filtering, then define behavior for immediate children, keys, directories, and both before adding coverage.

Written by the indexing model from the issue text.

Description

While .List(key) is useful if I want everything under the directory/root passed to it, there are some aspects of an ls type action which are very useful but missing:

  1. Non-Recursive Listing or depth specification
  2. What type of children to return

For the first I want to be able to get just the immediate children. For the second I want to be able to get back "directories", "keys", or both. For example something like:

kv.List("foo/bar/","directory",false)

...where false is a flag for recursion, and the return is a list of sub directories in "foo/bar". Alternatively making the second argument "keys" would only return keys, and "any" would return both. Passing true for the third argument would indicate I want all of whatever type under that prefix.

Alternatively we could instead of 'recurse boolwe could use adepthparameter wheredepth=0means no recursion, anddepth=5` means you wild get listing for up to 5 levels down from the given prefix.

Obviously the example would break the existing API so I'd be open to another name such as ListFilter or something ti identify it is a bit stronger than a basic List call

Dominant language
Go
Stars
847
Forks
204
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from docker/libkv

All issues in docker/libkv

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.