Skip to content

Commit

Permalink
Fixes bug if kubeconfig yaml isn't fully formed (v0.3.2 -> v0.3.3)
Browse files Browse the repository at this point in the history
  • Loading branch information
TheLonelyGhost committed Nov 22, 2019
1 parent f7766a6 commit bf4d694
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
We follow [Semantic Versioning](http://semver.org/) as a way of measuring stability of an update. This
means we will never make a backwards-incompatible change within a major version of the project.

## [0.3.3] - 2019-11-22

- Fixes stack trace when `current-context:` yaml fragment is not part of the same file as the list of contexts

## [0.3.2] - 2019-11-07

- Fixes typo in source code misspelling one of the properties we're trying to log the value of
Expand Down
2 changes: 1 addition & 1 deletion oc_auth/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.3.2'
__version__ = '0.3.3'
8 changes: 8 additions & 0 deletions oc_auth/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ def get_context_mapping(kube_config: KubeConfig, name=_missing, cluster=None, cr

if name:
for config in kube_config.each_config():
if not config.value:
continue
if 'contexts' not in config.value:
continue
for context in config.value['contexts']:
Expand All @@ -70,6 +72,8 @@ def get_context_mapping(kube_config: KubeConfig, name=_missing, cluster=None, cr

def get_user(kube_config: KubeConfig, name: str) -> KubeConfigDataSnippet:
for config in kube_config.each_config():
if not config.value:
continue
if 'users' not in config.value:
continue
for user in config.value['users']:
Expand All @@ -84,6 +88,8 @@ def get_user(kube_config: KubeConfig, name: str) -> KubeConfigDataSnippet:
}
logging.warning('Missing kubectl user {!r}. Creating it from the info given'.format(name))
for config in kube_config.each_config():
if not config.value:
continue
if 'users' not in config.value:
config.value['users'] = []
config.value['users'].append(user)
Expand All @@ -95,6 +101,8 @@ def get_user(kube_config: KubeConfig, name: str) -> KubeConfigDataSnippet:

def get_cluster(kube_config: KubeConfig, name: str) -> KubeConfigDataSnippet:
for config in kube_config.each_config():
if not config.value:
continue
if 'clusters' not in config.value:
continue
for cluster in config.value['clusters']:
Expand Down

0 comments on commit bf4d694

Please sign in to comment.