Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use yaml.safe_load/dump #57

Merged
merged 1 commit into from
Jan 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion kubernetes_asyncio/config/kube_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,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
6 changes: 3 additions & 3 deletions kubernetes_asyncio/config/kube_config_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -853,15 +853,15 @@ async def test_ssl_with_relative_ssl_files(self):
async 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()
await 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 @@ -874,7 +874,7 @@ def test_list_kube_config_contexts(self):
contexts)

async 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 = await new_client_from_config(
config_file=config_file, context="simple_token")
self.assertEqual(TEST_HOST, client.configuration.host)
Expand Down
2 changes: 1 addition & 1 deletion kubernetes_asyncio/e2e_test/test_extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ async def test_create_deployment(self):
- containerPort: 80
'''
resp = await api.create_namespaced_deployment(
body=yaml.load(deployment % name),
body=yaml.safe_load(deployment % name),
namespace="default")
resp = await api.read_namespaced_deployment(name, 'default')
self.assertIsNotNone(resp)
Expand Down