Skip to content

Commit 0779fc9

Browse files
committed
Fix collection of execptions when applying yaml
This fixes of all tests and keeps the original API. It's the users responsiblility to do something the execptions when using `create_from_dict`, no air bag or breaks are supplied here.
1 parent 18f45c9 commit 0779fc9

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

kubernetes/e2e_test/test_utils.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ def test_create_apps_deployment_from_yaml_obj(self):
7575
name="nginx-app", namespace="default",
7676
body={})
7777

78-
7978
def test_create_extensions_deployment_from_yaml(self):
8079
"""
8180
Should be able to create an extensions/v1beta1 deployment.

kubernetes/utils/create_from_yaml.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,16 @@ def create_from_yaml(
6060

6161
yml_document_all = yaml.safe_load_all(yaml_file)
6262
# Load all documents from a single YAML file
63+
fail_exceptions = []
64+
6365
for yml_document in yml_document_all:
64-
create_from_dict(k8s_client, yml_document, verbose,
65-
**kwargs)
66+
exceptions = create_from_dict(k8s_client, yml_document, verbose,
67+
**kwargs)
68+
if exceptions:
69+
fail_exceptions.extend(exceptions)
70+
71+
if fail_exceptions:
72+
raise FailToCreateError(fail_exceptions)
6673

6774

6875
def create_from_dict(k8s_client, yml_document, verbose=False, **kwargs):
@@ -94,7 +101,7 @@ def create_from_dict(k8s_client, yml_document, verbose=False, **kwargs):
94101

95102
# In case we have exceptions waiting for us, raise them
96103
if api_exceptions:
97-
raise FailToCreateError(api_exceptions)
104+
return api_exceptions
98105

99106

100107
def create_from_yaml_single_item(

0 commit comments

Comments
 (0)