Skip to content

Commit

Permalink
feat(env): pass additional ssl and url replace env to child process
Browse files Browse the repository at this point in the history
  • Loading branch information
viceice committed Aug 16, 2023
1 parent d45cf97 commit d4e582e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/util/exec/env.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ describe('util/exec/env', () => {
'LC_ALL',
'LANG',
'DOCKER_HOST',
'SSL_CERT_FILE',
'URL_REPLACE_1_FROM',
'URL_REPLACE_1_TO',
];

beforeEach(() => {
Expand All @@ -33,6 +36,9 @@ describe('util/exec/env', () => {
LC_ALL: 'LC_ALL',
NO_PROXY: 'NO_PROXY',
PATH: 'PATH',
SSL_CERT_FILE: 'SSL_CERT_FILE',
URL_REPLACE_1_FROM: 'URL_REPLACE_1_FROM',
URL_REPLACE_1_TO: 'URL_REPLACE_1_TO',
});
});

Expand Down
12 changes: 12 additions & 0 deletions lib/util/exec/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ const basicEnvVars = [
'DOCKER_HOST',
'DOCKER_TLS_VERIFY',
'DOCKER_CERT_PATH',
// Custom certificte variables
// https://github.com/containerbase/base/blob/main/docs/custom-root-ca.md
'SSL_CERT_DIR',
'SSL_CERT_FILE',
'NODE_EXTRA_CA_CERTS',
];

export function getChildProcessEnv(
Expand All @@ -29,5 +34,12 @@ export function getChildProcessEnv(
env[envVar] = process.env[envVar];
}
});

// Copy containerbase url replacements
for (const key of Object.keys(process.env)) {
if (/^URL_REPLACE_\d+_(?:FROM|TO)$/.test(key)) {
env[key] = process.env[key];
}
}
return env;
}

0 comments on commit d4e582e

Please sign in to comment.