Skip to content
This repository has been archived by the owner on Mar 13, 2022. It is now read-only.

Commit

Permalink
Re-using the _get_kube_config_loader in _get_kube_config_loader_for_y…
Browse files Browse the repository at this point in the history
…aml_file
  • Loading branch information
vishnu667 committed May 14, 2020
1 parent ab51510 commit 27a1b81
Showing 1 changed file with 8 additions and 17 deletions.
25 changes: 8 additions & 17 deletions config/kube_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -688,28 +688,19 @@ def save_config(self, path):
yaml.safe_dump(self.config_files[path], f,
default_flow_style=False)


def _get_kube_config_loader_for_yaml_file(
filename, persist_config=False, **kwargs):

kcfg = KubeConfigMerger(filename)
if persist_config and 'config_persister' not in kwargs:
kwargs['config_persister'] = kcfg.save_changes

if kcfg.config is None:
raise ConfigException(
'Invalid kube-config file. '
'No configuration found.')

return KubeConfigLoader(
config_dict=kcfg.config,
config_base_path=None,
return _get_kube_config_loader(
filename=filename,
persist_config=persist_config,
**kwargs)

def _get_kube_config_loader(
filename=None,config_dict=None, persist_config=False, **kwargs):

if (config_dict is None):
filename=None,
config_dict=None,
persist_config=False,
**kwargs):
if config_dict is None:
kcfg = KubeConfigMerger(filename)
if persist_config and 'config_persister' not in kwargs:
kwargs['config_persister'] = kcfg.save_changes
Expand Down

0 comments on commit 27a1b81

Please # to comment.