From 147f43c6a076f2eeb8ee38a88a734ec48e39fe9c Mon Sep 17 00:00:00 2001 From: Lauri Nevala Date: Tue, 29 Sep 2020 14:10:36 +0300 Subject: [PATCH] Add NO_PROXY to shell env Signed-off-by: Lauri Nevala --- src/main/kubectl.ts | 8 ++++++-- src/main/shell-session.ts | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/kubectl.ts b/src/main/kubectl.ts index ee5dce192d..198bb7af2a 100644 --- a/src/main/kubectl.ts +++ b/src/main/kubectl.ts @@ -283,7 +283,9 @@ export class Kubectl { bashScript += "fi\n" bashScript += `export PATH="${helmPath}:${kubectlPath}:$PATH"\n` bashScript += "export KUBECONFIG=\"$tempkubeconfig\"\n" - bashScript += "export NO_PROXY=localhost,127.0.0.1,$NO_PROXY\n" + bashScript += "if [ \"$NO_PROXY\" != \"localhost,127.0.0.1\" ]; then\n" + bashScript += " export NO_PROXY=\"localhost,127.0.0.1,$NO_PROXY\"\n" + bashScript += "fi\n" bashScript += "unset tempkubeconfig\n" await fsPromises.writeFile(bashScriptPath, bashScript.toString(), { mode: 0o644 }) @@ -309,7 +311,9 @@ export class Kubectl { zshScript += "d=${d/#:/}\n" zshScript += "export PATH=\"$helmpath:$kubectlpath:${d/%:/}\"\n" zshScript += "export KUBECONFIG=\"$tempkubeconfig\"\n" - zshScript += "export NO_PROXY=localhost,127.0.0.1,$NO_PROXY\n" + zshScript += "if [ \"$NO_PROXY\" != \"localhost,127.0.0.1\" ]; then\n" + zshScript += " export NO_PROXY=\"localhost,127.0.0.1,$NO_PROXY\"\n" + zshScript += "fi\n" zshScript += "unset tempkubeconfig\n" zshScript += "unset OLD_ZDOTDIR\n" await fsPromises.writeFile(zshScriptPath, zshScript.toString(), { mode: 0o644 }) diff --git a/src/main/shell-session.ts b/src/main/shell-session.ts index 1d9d722f57..962074c803 100644 --- a/src/main/shell-session.ts +++ b/src/main/shell-session.ts @@ -125,6 +125,8 @@ export class ShellSession extends EventEmitter { if (this.preferences.httpsProxy) { env["HTTPS_PROXY"] = this.preferences.httpsProxy } + const no_proxy = ["localhost", "127.0.0.1", env["NO_PROXY"]] + env["NO_PROXY"] = no_proxy.filter(address => !!address).join() if (env.DEBUG) { // do not pass debug option to bash delete env["DEBUG"] }