From 8da8d7a072643c04c167c48e02640385130b00ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Fern=C3=A1ndez?= <fmartin91@gmail.com> Date: Sat, 25 Jan 2020 15:30:43 -0300 Subject: [PATCH] feat: Add DOCKER_HOST to child env (#5222) Currently the DOCKER_HOST env variable is not passed to the child environment making it impossible to use a non default docker host. --- lib/util/exec/env.ts | 9 ++++++++- test/util/env.spec.ts | 11 ++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/lib/util/exec/env.ts b/lib/util/exec/env.ts index 5da3870816..27a2a61837 100644 --- a/lib/util/exec/env.ts +++ b/lib/util/exec/env.ts @@ -1,4 +1,11 @@ -const basicEnvVars = ['HTTP_PROXY', 'HTTPS_PROXY', 'NO_PROXY', 'HOME', 'PATH']; +const basicEnvVars = [ + 'HTTP_PROXY', + 'HTTPS_PROXY', + 'NO_PROXY', + 'HOME', + 'PATH', + 'DOCKER_HOST', +]; export function getChildProcessEnv( customEnvVars: string[] = [] diff --git a/test/util/env.spec.ts b/test/util/env.spec.ts index c8e057c96f..d9ae4710b5 100644 --- a/test/util/env.spec.ts +++ b/test/util/env.spec.ts @@ -1,7 +1,14 @@ import { getChildProcessEnv } from '../../lib/util/exec/env'; describe('getChildProcess environment when trustlevel set to low', () => { - const envVars = ['HTTP_PROXY', 'HTTPS_PROXY', 'NO_PROXY', 'HOME', 'PATH']; + const envVars = [ + 'HTTP_PROXY', + 'HTTPS_PROXY', + 'NO_PROXY', + 'HOME', + 'PATH', + 'DOCKER_HOST', + ]; beforeEach(() => { envVars.forEach(env => { process.env[env] = env; @@ -13,6 +20,7 @@ describe('getChildProcess environment when trustlevel set to low', () => { it('returns default environment variables', () => { expect(getChildProcessEnv()).toMatchInlineSnapshot(` Object { + "DOCKER_HOST": "DOCKER_HOST", "HOME": "HOME", "HTTPS_PROXY": "HTTPS_PROXY", "HTTP_PROXY": "HTTP_PROXY", @@ -29,6 +37,7 @@ describe('getChildProcess environment when trustlevel set to low', () => { process.env.LANG = 'LANG'; expect(getChildProcessEnv(['LANG'])).toMatchInlineSnapshot(` Object { + "DOCKER_HOST": "DOCKER_HOST", "HOME": "HOME", "HTTPS_PROXY": "HTTPS_PROXY", "HTTP_PROXY": "HTTP_PROXY", -- GitLab