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

Commit dff473d

Browse files
committed
Add checks for None config file
1 parent 4c1ab55 commit dff473d

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

config/kube_config.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,11 @@ def __init__(self, config_dict, active_context=None,
140140
config_base_path="",
141141
config_persister=None):
142142

143-
if isinstance(config_dict, ConfigNode):
143+
if config_dict is None:
144+
raise ConfigException(
145+
'Invalid kube-config file. '
146+
'No configuration found.')
147+
elif isinstance(config_dict, ConfigNode):
144148
self._config = config_dict
145149
else:
146150
self._config = ConfigNode('kube-config', config_dict)
@@ -613,6 +617,11 @@ def _get_kube_config_loader_for_yaml_file(
613617
if persist_config and 'config_persister' not in kwargs:
614618
kwargs['config_persister'] = kcfg.save_changes()
615619

620+
if kcfg.config is None:
621+
raise ConfigException(
622+
'Invalid kube-config file. '
623+
'No configuration found.')
624+
616625
return KubeConfigLoader(
617626
config_dict=kcfg.config,
618627
config_base_path=None,

0 commit comments

Comments
 (0)