From e78a3031fa0a8009021d7f02b306060f60c21eb9 Mon Sep 17 00:00:00 2001 From: Kosea Kalema Date: Fri, 13 Mar 2026 11:09:17 +0300 Subject: [PATCH] Fix: properly load and parse NO_PROXY environment variable Signed-off-by: Kosea Kalema --- kubernetes/client/configuration.py | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/kubernetes/client/configuration.py b/kubernetes/client/configuration.py index 56c0624672..e606ef5e4f 100644 --- a/kubernetes/client/configuration.py +++ b/kubernetes/client/configuration.py @@ -161,15 +161,28 @@ def __init__(self, host="http://localhost", self.proxy = None """Proxy URL """ - self.no_proxy = None -# Load proxy from environment variables (if set) + + self.no_proxy = [] + # Load proxy from environment variables (if set) if os.getenv("HTTPS_PROXY"): self.proxy = os.getenv("HTTPS_PROXY") if os.getenv("https_proxy"): self.proxy = os.getenv("https_proxy") if os.getenv("HTTP_PROXY"): self.proxy = os.getenv("HTTP_PROXY") if os.getenv("http_proxy"): self.proxy = os.getenv("http_proxy") - # Load no_proxy from environment variables (if set) - if os.getenv("NO_PROXY"): self.no_proxy = os.getenv("NO_PROXY") - if os.getenv("no_proxy"): self.no_proxy = os.getenv("no_proxy") + # Load and parse no_proxy from environment variables + # Check for uppercase NO_PROXY first (should take precedence) + no_proxy_env = None + # Check if NO_PROXY exists in environment (even if empty) + if "NO_PROXY" in os.environ: + no_proxy_env = os.getenv("NO_PROXY") + elif "no_proxy" in os.environ: + no_proxy_env = os.getenv("no_proxy") + + if no_proxy_env is not None and no_proxy_env != "": + self.no_proxy = [ + domain.strip() + for domain in no_proxy_env.split(",") + if domain.strip() + ] """bypass proxy for host in the no_proxy list. """ self.proxy_headers = None @@ -411,4 +424,4 @@ def get_host_from_settings(self, index, variables=None): url = url.replace("{" + variable_name + "}", used_value) - return url + return url \ No newline at end of file