From 0b5ed4b8f6c734f3b4e3712222c3126a2809a65a Mon Sep 17 00:00:00 2001 From: Lauri Nevala Date: Wed, 30 Sep 2020 11:29:46 +0300 Subject: [PATCH] Revert NO_PROXY mangle Signed-off-by: Lauri Nevala --- src/main/kubectl.ts | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/main/kubectl.ts b/src/main/kubectl.ts index ffa5e06d66..6e4ba93831 100644 --- a/src/main/kubectl.ts +++ b/src/main/kubectl.ts @@ -284,10 +284,11 @@ export class Kubectl { bashScript += `export PATH="${helmPath}:${kubectlPath}:$PATH"\n` bashScript += "export KUBECONFIG=\"$tempkubeconfig\"\n" - bashScript += "NO_PROXY=\",${NO_PROXY:-localhost},\"\n" - bashScript += "NO_PROXY=\"${NO_PROXY//,localhost,/,}\"\n" - bashScript += "NO_PROXY=\"${NO_PROXY//,127.0.0.1,/,}\"\n" - bashScript += "NO_PROXY=\"localhost,127.0.0.1${NO_PROXY%,}\"\n" + bashScript += "if [ -z \"$NO_PROXY\" ]; then\n" + bashScript += " export NO_PROXY=\"localhost,127.0.0.1\"\n" + bashScript += "elif [ \"$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 }) @@ -313,10 +314,11 @@ export class Kubectl { zshScript += "d=${d/#:/}\n" zshScript += "export PATH=\"$helmpath:$kubectlpath:${d/%:/}\"\n" zshScript += "export KUBECONFIG=\"$tempkubeconfig\"\n" - zshScript += "NO_PROXY=\",${NO_PROXY:-localhost},\"\n" - zshScript += "NO_PROXY=\"${NO_PROXY//,localhost,/,}\"\n" - zshScript += "NO_PROXY=\"${NO_PROXY//,127.0.0.1,/,}\"\n" - zshScript += "NO_PROXY=\"localhost,127.0.0.1${NO_PROXY%,}\"\n" + zshScript += "if test -z \"$NO_PROXY\"; then\n" + zshScript += " export NO_PROXY=\"localhost,127.0.0.1\"\n" + zshScript += "elif [ \"$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 })