Skip to content

Commit

Permalink
Merge pull request #1968 from FlorianJDF/custom_client_config_new_client
Browse files Browse the repository at this point in the history
kube-config: add custom client configuration injection
  • Loading branch information
k8s-ci-robot committed Feb 19, 2024
2 parents 7712421 + 0bb2314 commit d36ec43
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions kubernetes/base/config/kube_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -866,32 +866,36 @@ def load_kube_config_from_dict(config_dict, context=None,
def new_client_from_config(
config_file=None,
context=None,
persist_config=True):
persist_config=True,
client_configuration=None):
"""
Loads configuration the same as load_kube_config but returns an ApiClient
to be used with any API object. This will allow the caller to concurrently
talk with multiple clusters.
"""
client_config = type.__call__(Configuration)
if client_configuration is None:
client_configuration = type.__call__(Configuration)
load_kube_config(config_file=config_file, context=context,
client_configuration=client_config,
client_configuration=client_configuration,
persist_config=persist_config)
return ApiClient(configuration=client_config)
return ApiClient(configuration=client_configuration)


def new_client_from_config_dict(
config_dict=None,
context=None,
persist_config=True,
temp_file_path=None):
temp_file_path=None,
client_configuration=None):
"""
Loads configuration the same as load_kube_config_from_dict but returns an ApiClient
to be used with any API object. This will allow the caller to concurrently
talk with multiple clusters.
"""
client_config = type.__call__(Configuration)
if client_configuration is None:
client_configuration = type.__call__(Configuration)
load_kube_config_from_dict(config_dict=config_dict, context=context,
client_configuration=client_config,
client_configuration=client_configuration,
persist_config=persist_config,
temp_file_path=temp_file_path)
return ApiClient(configuration=client_config)
return ApiClient(configuration=client_configuration)

0 comments on commit d36ec43

Please sign in to comment.