-
Notifications
You must be signed in to change notification settings - Fork 166
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Patch fix for proxy not working from kubeconfig
- Loading branch information
1 parent
36a440c
commit 78e0d25
Showing
3 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# NOTE: This is a workaround for the issue described here: | ||
# https://github.com/kubernetes-client/python/pull/1863 | ||
|
||
from __future__ import annotations | ||
|
||
from kubernetes.client import configuration | ||
from kubernetes.config import kube_config | ||
|
||
|
||
class KubeConfigLoader(kube_config.KubeConfigLoader): | ||
def _load_cluster_info(self): | ||
super()._load_cluster_info() | ||
|
||
if "proxy-url" in self._cluster: | ||
self.proxy = self._cluster["proxy-url"] | ||
|
||
def _set_config(self, client_configuration: Configuration): | ||
super()._set_config(client_configuration) | ||
|
||
key = "proxy" | ||
if key in self.__dict__: | ||
setattr(client_configuration, key, getattr(self, key)) | ||
|
||
|
||
class Configuration(configuration.Configuration): | ||
def __init__( | ||
self, | ||
proxy: str | None = None, | ||
**kwargs, | ||
): | ||
super().__init__(**kwargs) | ||
|
||
self.proxy = proxy | ||
|
||
|
||
configuration.Configuration = Configuration | ||
kube_config.KubeConfigLoader = KubeConfigLoader |
File renamed without changes.