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 #111 from xvello/xvello/safe_load
Browse files Browse the repository at this point in the history
Use yaml.safe_load and yaml.safe_dump
  • Loading branch information
k8s-ci-robot authored Jan 8, 2019
2 parents 5c242ea + 13ff518 commit bd9a852
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion config/kube_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ def get_with_name(self, name, safe=False):
def _get_kube_config_loader_for_yaml_file(filename, **kwargs):
with open(filename) as f:
return KubeConfigLoader(
config_dict=yaml.load(f),
config_dict=yaml.safe_load(f),
config_base_path=os.path.abspath(os.path.dirname(filename)),
**kwargs)

Expand Down
9 changes: 6 additions & 3 deletions config/kube_config_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -896,14 +896,16 @@ def test_ssl_with_relative_ssl_files(self):
def test_load_kube_config(self):
expected = FakeConfig(host=TEST_HOST,
token=BEARER_TOKEN_FORMAT % TEST_DATA_BASE64)
config_file = self._create_temp_file(yaml.dump(self.TEST_KUBE_CONFIG))
config_file = self._create_temp_file(
yaml.safe_dump(self.TEST_KUBE_CONFIG))
actual = FakeConfig()
load_kube_config(config_file=config_file, context="simple_token",
client_configuration=actual)
self.assertEqual(expected, actual)

def test_list_kube_config_contexts(self):
config_file = self._create_temp_file(yaml.dump(self.TEST_KUBE_CONFIG))
config_file = self._create_temp_file(
yaml.safe_dump(self.TEST_KUBE_CONFIG))
contexts, active_context = list_kube_config_contexts(
config_file=config_file)
self.assertDictEqual(self.TEST_KUBE_CONFIG['contexts'][0],
Expand All @@ -916,7 +918,8 @@ def test_list_kube_config_contexts(self):
contexts)

def test_new_client_from_config(self):
config_file = self._create_temp_file(yaml.dump(self.TEST_KUBE_CONFIG))
config_file = self._create_temp_file(
yaml.safe_dump(self.TEST_KUBE_CONFIG))
client = new_client_from_config(
config_file=config_file, context="simple_token")
self.assertEqual(TEST_HOST, client.configuration.host)
Expand Down

0 comments on commit bd9a852

Please sign in to comment.