Skip to content

Commit 6e8bc69

Browse files
committed
fix: actually allow vault to export all secrets by default
1 parent ecb43cc commit 6e8bc69

2 files changed

Lines changed: 10 additions & 10 deletions

File tree

src/secrets/CommandEnv.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ class CommandEnv extends CommandPolykey {
2727
'command and arguments formatted as [envPaths...][-- cmd [cmdArgs...]]',
2828
binParsers.parseEnvArgs,
2929
);
30-
this.passThroughOptions();
30+
this.passThroughOptions(); // Let -- pass through as-is to parse as delimiter for cmd
3131
this.action(
3232
async (
33-
args: [Array<[string, string, string?]>, Array<string>],
33+
args: [Array<[string, string?, string?]>, Array<string>],
3434
options,
3535
) => {
3636
args[1].shift();
@@ -93,10 +93,10 @@ class CommandEnv extends CommandPolykey {
9393
let first = true;
9494
for (const envVariable of envVariables) {
9595
const [nameOrId, secretName, secretNameNew] = envVariable;
96-
secretRenameMap.set(secretName, secretNameNew);
96+
secretRenameMap.set(secretName ?? '/', secretNameNew);
9797
await writer.write({
98-
nameOrId,
99-
secretName,
98+
nameOrId: nameOrId,
99+
secretName: secretName ?? '/',
100100
metadata: first ? auth : undefined,
101101
});
102102
first = false;

src/utils/parsers.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,13 +124,13 @@ function parseSecretPathValue(secretPath: string): [string, string, string?] {
124124
return [vaultName, directoryPath, value];
125125
}
126126

127-
function parseSecretPathEnv(secretPath: string): [string, string, string?] {
127+
function parseSecretPathEnv(secretPath: string): [string, string?, string?] {
128128
// The colon character `:` is prohibited in vaultName, so it's first occurence
129129
// means that this is the delimiter between vaultName and secretPath.
130130
const colonIndex = secretPath.indexOf(':');
131131
// If no colon exists, treat entire string as vault name
132132
if (colonIndex === -1) {
133-
return [parseVaultName(secretPath), '', undefined];
133+
return [parseVaultName(secretPath), undefined, undefined];
134134
}
135135
// Calculate contents before the `=` separator
136136
const vaultNamePart = secretPath.substring(0, colonIndex);
@@ -229,9 +229,9 @@ const parseSeedNodes: (data: string) => [SeedNodes, boolean] =
229229
*/
230230
function parseEnvArgs(
231231
value: string,
232-
prev: [Array<[string, string, string?]>, Array<string>] | undefined,
233-
): [Array<[string, string, string?]>, Array<string>] {
234-
const current: [Array<[string, string, string?]>, Array<string>] = prev ?? [
232+
prev: [Array<[string, string?, string?]>, Array<string>] | undefined,
233+
): [Array<[string, string?, string?]>, Array<string>] {
234+
const current: [Array<[string, string?, string?]>, Array<string>] = prev ?? [
235235
[],
236236
[],
237237
];

0 commit comments

Comments
 (0)