Skip to content

Commit

Permalink
Unify kv:key list output in local vs remote case
Browse files Browse the repository at this point in the history
  • Loading branch information
JacksonKearl committed Aug 8, 2023
1 parent 6de3c5e commit 34b99fa
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions packages/wrangler/src/kv/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import {
} from "./helpers";
import type { EventNames } from "../metrics";
import type { CommonYargsArgv } from "../yargs-types";
import type { KeyValue } from "./helpers";
import type { KeyValue, NamespaceKeyInfo } from "./helpers";

export function kvNamespace(kvYargs: CommonYargsArgv) {
return kvYargs
Expand Down Expand Up @@ -340,15 +340,20 @@ export const kvKey = (kvYargs: CommonYargsArgv) => {
const config = readConfig(args.config, args);
const namespaceId = getKVNamespaceId(args, config);

let result;
let result: NamespaceKeyInfo[];
let metricEvent: EventNames;
if (args.local) {
const kvGateway = localGateway(
args.persistTo,
config.configPath,
namespaceId
);
result = await kvGateway.list();
result = (await kvGateway.list({ prefix })).keys.map((key) => ({
name: key.name,
expiration: key.expiration,
metadata:
key.metadata === undefined ? undefined : JSON.parse(key.metadata),
}));
metricEvent = "list kv keys (local)";
} else {
const accountId = await requireAuth(config);
Expand Down

0 comments on commit 34b99fa

Please sign in to comment.