From a29bf292cce41060561c9a11a2859f80862e9023 Mon Sep 17 00:00:00 2001 From: Quentin Lemaire Date: Fri, 6 Sep 2019 09:57:16 +0200 Subject: [PATCH] Add checks for None config file --- config/kube_config.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/config/kube_config.py b/config/kube_config.py index 3384d272..9f3df7ea 100644 --- a/config/kube_config.py +++ b/config/kube_config.py @@ -140,7 +140,11 @@ def __init__(self, config_dict, active_context=None, config_base_path="", config_persister=None): - if isinstance(config_dict, ConfigNode): + if config_dict is None: + raise ConfigException( + 'Invalid kube-config. ' + 'Expected config_dict to not be None.') + elif isinstance(config_dict, ConfigNode): self._config = config_dict else: self._config = ConfigNode('kube-config', config_dict) @@ -613,6 +617,11 @@ def _get_kube_config_loader_for_yaml_file( 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,