From 9513a6b582c8c3d21f255e3b2e445afb07cc0ace Mon Sep 17 00:00:00 2001 From: Lauri Nevala Date: Wed, 30 Sep 2020 13:09:04 +0300 Subject: [PATCH] Mangle NO_PROXY harder Signed-off-by: Lauri Nevala --- src/main/kubectl.ts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/main/kubectl.ts b/src/main/kubectl.ts index 6e4ba93831..672d93cf65 100644 --- a/src/main/kubectl.ts +++ b/src/main/kubectl.ts @@ -284,11 +284,11 @@ export class Kubectl { bashScript += `export PATH="${helmPath}:${kubectlPath}:$PATH"\n` bashScript += "export KUBECONFIG=\"$tempkubeconfig\"\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 += "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 += "export NO_PROXY\n" bashScript += "unset tempkubeconfig\n" await fsPromises.writeFile(bashScriptPath, bashScript.toString(), { mode: 0o644 }) @@ -314,11 +314,11 @@ export class Kubectl { zshScript += "d=${d/#:/}\n" zshScript += "export PATH=\"$helmpath:$kubectlpath:${d/%:/}\"\n" zshScript += "export KUBECONFIG=\"$tempkubeconfig\"\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 += "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 += "export NO_PROXY\n" zshScript += "unset tempkubeconfig\n" zshScript += "unset OLD_ZDOTDIR\n" await fsPromises.writeFile(zshScriptPath, zshScript.toString(), { mode: 0o644 })