Skip to content
This repository has been archived by the owner on Aug 3, 2023. It is now read-only.

Add key listing functionality for workers kv subcommands #462

Merged
merged 8 commits into from
Aug 22, 2019

Conversation

gabbifish
Copy link
Contributor

@gabbifish gabbifish commented Aug 21, 2019

This PR closes #345. A clarification: this does not list all KV pairs in a Workers KV instance, but instead, lists all keys and (if present) their expiration timestamps.

Usage without prefix filter:

$ /wrangler kv list-keys 06779da6940b431db6e566b4846d64db
[{"name":"key1"},{"name":"key2"},{"name":"key3"}]

With prefix filter:

$ wrangler kv list-keys 06779da6940b431db6e566b4846d64db --prefix taylor
[{"name":"taylor"}]

I made sure that the logic handles pagination correctly for KV namespaces with >1000 keys :)
There are todo comments in my code about particular pieces of logic I'd like to write more elegantly, if possible. I'd love if you could toss ideas there if you have any.

Right now, I print out the results of every page as wrangler gets them (instead of storing them in memory and outputting them all at once). What do the reviewers think about this? I figured this was the best option because it wouldn't eat memory, but I'm curious what other folks think.

This PR will fail CI until cloudflare/cloudflare-rs#30 is merged.

@gabbifish gabbifish added status - needs review feature Feature requests and suggestions regression Something is broken, but works in previous releases labels Aug 21, 2019
@gabbifish gabbifish force-pushed the gabbi/list-all-keys branch from 0747df0 to edfe690 Compare August 21, 2019 18:35
src/commands/kv/list_keys.rs Outdated Show resolved Hide resolved
src/commands/kv/list_keys.rs Outdated Show resolved Hide resolved
src/commands/kv/list_keys.rs Outdated Show resolved Hide resolved
@gabbifish gabbifish merged commit 725ea2f into feat-kv-commands Aug 22, 2019
@delete-merged-branch delete-merged-branch bot deleted the gabbi/list-all-keys branch August 22, 2019 00:30
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature Feature requests and suggestions regression Something is broken, but works in previous releases
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants