Skip to content

Commit

Permalink
no_proxy fix (#132)
Browse files Browse the repository at this point in the history
* no_proxy fix
  • Loading branch information
m-wcislo authored Apr 22, 2023
1 parent c238ef0 commit 897debd
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ jobs:
--volumes-from kubeconfig \
-e KUBECONFIG=$K3D_KUBECONFIG \
-e KUBELET_VERSION=$K8S_VERSION \
-e HTTPS_PROXY=http://1.1.1.1 \
-e NO_PROXY=172.20.0.2 \
kubelibrary -i smoke /testcases/
- k3d/k3d-run:
step-name: Run Grafana examples
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## In progress
## [0.8.5] - 2022-04-22
### Fixed
- Fixed no_proxy setting

## [0.8.4] - 2022-04-10
### Fixed
Expand Down
6 changes: 6 additions & 0 deletions src/KubeLibrary/KubeLibrary.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ def __init__(self, kube_config=None, context=None, api_url=None, bearer_token=No
def get_proxy():
return environ.get('https_proxy') or environ.get('HTTPS_PROXY') or environ.get('http_proxy') or environ.get('HTTP_PROXY')

@staticmethod
def get_no_proxy():
return environ.get('no_proxy') or environ.get('NO_PROXY')

@staticmethod
def generate_alphanumeric_str(size):
"""Generates a random alphanumeric string with given size.
Expand Down Expand Up @@ -252,6 +256,7 @@ def reload_config(self, kube_config=None, context=None, api_url=None, bearer_tok
raise BearerTokenWithPrefixException
configuration = client.Configuration()
configuration._default.proxy = KubeLibrary.get_proxy()
configuration._default.no_proxy = KubeLibrary.get_no_proxy()
configuration.api_key["authorization"] = bearer_token
configuration.api_key_prefix['authorization'] = 'Bearer'
configuration.host = api_url
Expand All @@ -261,6 +266,7 @@ def reload_config(self, kube_config=None, context=None, api_url=None, bearer_tok
try:
config.load_kube_config(kube_config, context)
client.Configuration._default.proxy = KubeLibrary.get_proxy()
client.Configuration._default.no_proxy = KubeLibrary.get_no_proxy()
except TypeError:
logger.error('Neither KUBECONFIG nor ~/.kube/config available.')

Expand Down
2 changes: 1 addition & 1 deletion src/KubeLibrary/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version = "0.8.4"
version = "0.8.5"

0 comments on commit 897debd

Please sign in to comment.