Merge pull request #163 from goddenrich/kube-configs-with-no-contexts-clusters-users

Merging configs with missing fields
This commit is contained in:
Kubernetes Prow Robot 2019-09-24 14:55:57 -07:00 committed by GitHub
commit 9f73cc68c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

View File

@ -586,7 +586,7 @@ class KubeConfigMerger:
self.config_merged = ConfigNode(path, config_merged, path)
for item in ('clusters', 'contexts', 'users'):
self._merge(item, config[item], path)
self._merge(item, config.get(item, {}), path)
self.config_files[path] = config
def _merge(self, item, add_cfg, path):

View File

@ -1355,13 +1355,17 @@ class TestKubeConfigMerger(BaseTestCase):
},
]
}
TEST_KUBE_CONFIG_PART4 = {
"current-context": "no_user",
}
def _create_multi_config(self):
files = []
for part in (
self.TEST_KUBE_CONFIG_PART1,
self.TEST_KUBE_CONFIG_PART2,
self.TEST_KUBE_CONFIG_PART3):
self.TEST_KUBE_CONFIG_PART3,
self.TEST_KUBE_CONFIG_PART4):
files.append(self._create_temp_file(yaml.safe_dump(part)))
return ENV_KUBECONFIG_PATH_SEPARATOR.join(files)