Skip to content

Commit

Permalink
Adds some love for Windows users
Browse files Browse the repository at this point in the history
  • Loading branch information
TheLonelyGhost committed Nov 7, 2019
1 parent 34fc365 commit c2d641a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ means we will never make a backwards-incompatible change within a major version
## [UNRELEASED]

- Uses the TLS verification settings already present in the kube config
- Adds Windows support for path separation

## [0.2.0] - 2019-10-25

Expand Down
13 changes: 10 additions & 3 deletions oc_auth/kube_config.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
import logging
import platform
import os
from typing import Any, Dict, List, Iterator, Union

from ruamel import yaml


_missing = object()
_default_kube_config = os.path.expanduser('~/.kube/config')

if platform.system() == 'Windows':
_path_separator = ';'
else:
_path_separator = ':'


class KubeConfigData(object):
Expand Down Expand Up @@ -55,7 +62,7 @@ def persist(self):


class KubeConfig(object):
def __init__(self, config_files: List[str] = [os.path.expanduser('~/.kube/config')]):
def __init__(self, config_files: List[str] = [_default_kube_config]):
self.configs: List[KubeConfigData] = []
for filename in config_files:
if not filename:
Expand All @@ -66,8 +73,8 @@ def __init__(self, config_files: List[str] = [os.path.expanduser('~/.kube/config

@classmethod
def find_from_env(cls):
path = os.environ.get('KUBECONFIG', os.path.expanduser('~/.kube/config'))
files = path.split(':')
path = os.environ.get('KUBECONFIG', _default_kube_config)
files = path.split(_path_separator)
return cls(config_files=files)

@property
Expand Down

0 comments on commit c2d641a

Please sign in to comment.