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

Commit 9f73cc6

Browse files
authored
Merge pull request #163 from goddenrich/kube-configs-with-no-contexts-clusters-users
Merging configs with missing fields
2 parents c700068 + 7ce0198 commit 9f73cc6

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

config/kube_config.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ def load_config(self, path):
586586
self.config_merged = ConfigNode(path, config_merged, path)
587587

588588
for item in ('clusters', 'contexts', 'users'):
589-
self._merge(item, config[item], path)
589+
self._merge(item, config.get(item, {}), path)
590590
self.config_files[path] = config
591591

592592
def _merge(self, item, add_cfg, path):

config/kube_config_test.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -1355,13 +1355,17 @@ class TestKubeConfigMerger(BaseTestCase):
13551355
},
13561356
]
13571357
}
1358+
TEST_KUBE_CONFIG_PART4 = {
1359+
"current-context": "no_user",
1360+
}
13581361

13591362
def _create_multi_config(self):
13601363
files = []
13611364
for part in (
13621365
self.TEST_KUBE_CONFIG_PART1,
13631366
self.TEST_KUBE_CONFIG_PART2,
1364-
self.TEST_KUBE_CONFIG_PART3):
1367+
self.TEST_KUBE_CONFIG_PART3,
1368+
self.TEST_KUBE_CONFIG_PART4):
13651369
files.append(self._create_temp_file(yaml.safe_dump(part)))
13661370
return ENV_KUBECONFIG_PATH_SEPARATOR.join(files)
13671371

0 commit comments

Comments
 (0)