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

Commit

Permalink
Add checks for None config file
Browse files Browse the repository at this point in the history
  • Loading branch information
qlemaire22 committed Sep 17, 2019
1 parent 4c1ab55 commit dff473d
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion config/kube_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 file. '
'No configuration found.')
elif isinstance(config_dict, ConfigNode):
self._config = config_dict
else:
self._config = ConfigNode('kube-config', config_dict)
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit dff473d

Please sign in to comment.