Skip to content

Commit 0bb2314

Browse files
committed
kube-config: add custom client configuration injection
1 parent 5a96bbc commit 0bb2314

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

kubernetes/base/config/kube_config.py

+12-8
Original file line numberDiff line numberDiff line change
@@ -860,32 +860,36 @@ def load_kube_config_from_dict(config_dict, context=None,
860860
def new_client_from_config(
861861
config_file=None,
862862
context=None,
863-
persist_config=True):
863+
persist_config=True,
864+
client_configuration=None):
864865
"""
865866
Loads configuration the same as load_kube_config but returns an ApiClient
866867
to be used with any API object. This will allow the caller to concurrently
867868
talk with multiple clusters.
868869
"""
869-
client_config = type.__call__(Configuration)
870+
if client_configuration is None:
871+
client_configuration = type.__call__(Configuration)
870872
load_kube_config(config_file=config_file, context=context,
871-
client_configuration=client_config,
873+
client_configuration=client_configuration,
872874
persist_config=persist_config)
873-
return ApiClient(configuration=client_config)
875+
return ApiClient(configuration=client_configuration)
874876

875877

876878
def new_client_from_config_dict(
877879
config_dict=None,
878880
context=None,
879881
persist_config=True,
880-
temp_file_path=None):
882+
temp_file_path=None,
883+
client_configuration=None):
881884
"""
882885
Loads configuration the same as load_kube_config_from_dict but returns an ApiClient
883886
to be used with any API object. This will allow the caller to concurrently
884887
talk with multiple clusters.
885888
"""
886-
client_config = type.__call__(Configuration)
889+
if client_configuration is None:
890+
client_configuration = type.__call__(Configuration)
887891
load_kube_config_from_dict(config_dict=config_dict, context=context,
888-
client_configuration=client_config,
892+
client_configuration=client_configuration,
889893
persist_config=persist_config,
890894
temp_file_path=temp_file_path)
891-
return ApiClient(configuration=client_config)
895+
return ApiClient(configuration=client_configuration)

0 commit comments

Comments
 (0)