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

Commit

Permalink
Merge pull request #163 from goddenrich/kube-configs-with-no-contexts…
Browse files Browse the repository at this point in the history
…-clusters-users

Merging configs with missing fields
  • Loading branch information
k8s-ci-robot committed Sep 24, 2019
2 parents c700068 + 7ce0198 commit 9f73cc6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion config/kube_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ def load_config(self, path):
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):
Expand Down
6 changes: 5 additions & 1 deletion config/kube_config_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 9f73cc6

Please sign in to comment.