Skip to content

Commit f85a41f

Browse files
committed
renaming functions and setting to internal
1 parent aac4e35 commit f85a41f

File tree

2 files changed

+18
-15
lines changed

2 files changed

+18
-15
lines changed

config/kube_config.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -669,21 +669,15 @@ def __init__(self, paths):
669669
self.config_files = {}
670670
self.config_merged = None
671671
if hasattr(paths, 'read'):
672-
self.load_config_from_fileish(paths)
672+
self._load_config_from_file_like_object(paths)
673673
else:
674-
for path in paths.split(ENV_KUBECONFIG_PATH_SEPARATOR):
675-
if path:
676-
path = os.path.expanduser(path)
677-
if os.path.exists(path):
678-
self.paths.append(path)
679-
self.load_config(path)
680-
self.config_saved = copy.deepcopy(self.config_files)
674+
self._load_config_from_file_path(paths)
681675

682676
@property
683677
def config(self):
684678
return self.config_merged
685679

686-
def load_config_from_fileish(self, string):
680+
def _load_config_from_file_like_object(self, string):
687681
if hasattr(string, 'getvalue'):
688682
config = yaml.safe_load(string.getvalue())
689683
else:
@@ -693,6 +687,15 @@ def load_config_from_fileish(self, string):
693687
self.config_merged = copy.deepcopy(config)
694688
# doesn't need to do any further merging
695689

690+
def _load_config_from_file_path(self, string):
691+
for path in string.split(ENV_KUBECONFIG_PATH_SEPARATOR):
692+
if path:
693+
path = os.path.expanduser(path)
694+
if os.path.exists(path):
695+
self.paths.append(path)
696+
self.load_config(path)
697+
self.config_saved = copy.deepcopy(self.config_files)
698+
696699
def load_config(self, path):
697700
with open(path) as f:
698701
config = yaml.safe_load(f)

config/kube_config_test.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1248,7 +1248,7 @@ def test_ssl_with_relative_ssl_files(self):
12481248
finally:
12491249
shutil.rmtree(temp_dir)
12501250

1251-
def test_load_kube_config(self):
1251+
def test_load_kube_config_from_file_path(self):
12521252
expected = FakeConfig(host=TEST_HOST,
12531253
token=BEARER_TOKEN_FORMAT % TEST_DATA_BASE64)
12541254
config_file = self._create_temp_file(
@@ -1258,19 +1258,19 @@ def test_load_kube_config(self):
12581258
client_configuration=actual)
12591259
self.assertEqual(expected, actual)
12601260

1261-
def test_load_kube_config_from_fileish(self):
1261+
def test_load_kube_config_from_file_like_object(self):
12621262
expected = FakeConfig(host=TEST_HOST,
12631263
token=BEARER_TOKEN_FORMAT % TEST_DATA_BASE64)
1264-
config_fileish = io.StringIO()
1265-
config_fileish.write(yaml.safe_dump(self.TEST_KUBE_CONFIG))
1264+
config_file_like_object = io.StringIO()
1265+
config_file_like_object.write(yaml.safe_dump(self.TEST_KUBE_CONFIG))
12661266
actual = FakeConfig()
1267-
load_kube_config(config_file=config_fileish, context="simple_token", client_configuration=actual)
1267+
load_kube_config(config_file=config_file_like_object, context="simple_token",
1268+
client_configuration=actual)
12681269
self.assertEqual(expected, actual)
12691270

12701271
def test_load_kube_config_from_dict(self):
12711272
expected = FakeConfig(host=TEST_HOST,
12721273
token=BEARER_TOKEN_FORMAT % TEST_DATA_BASE64)
1273-
12741274
actual = FakeConfig()
12751275
load_kube_config_from_dict(config_dict=self.TEST_KUBE_CONFIG,
12761276
context="simple_token",

0 commit comments

Comments
 (0)