Skip to content

Commit b55fd09

Browse files
committed
fix: get_client() client_configuration
Support client_configuration provided via kwargs
1 parent 5be9955 commit b55fd09

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

ocp_resources/resource.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,14 @@ def get_client(
108108
config_dict=config_dict, context=context or None, **kwargs
109109
)
110110
)
111-
client_configuration = kwargs.get("client_configuration", kubernetes.client.Configuration())
111+
112+
kwargs_copy = copy.deepcopy(kwargs)
113+
if "client_configuration" in kwargs_copy:
114+
client_configuration = kwargs_copy["client_configuration"]
115+
del kwargs_copy["client_configuration"]
116+
else:
117+
client_configuration = kubernetes.client.Configuration()
118+
112119
try:
113120
# Ref: https://github.com/kubernetes-client/python/blob/v26.1.0/kubernetes/base/config/__init__.py
114121
LOGGER.info("Trying to get client via new_client_from_config")
@@ -136,7 +143,7 @@ def get_client(
136143
config_file=config_file,
137144
client_configuration=client_configuration,
138145
context=context or None,
139-
**kwargs,
146+
**kwargs_copy,
140147
)
141148
)
142149
except MaxRetryError:
@@ -145,7 +152,7 @@ def get_client(
145152
return kubernetes.dynamic.DynamicClient(
146153
client=kubernetes.config.incluster_config.load_incluster_config(
147154
client_configuration=client_configuration,
148-
try_refresh_token=kwargs.get("try_refresh_token", True),
155+
try_refresh_token=kwargs_copy.get("try_refresh_token", True),
149156
)
150157
)
151158

0 commit comments

Comments
 (0)