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.
This commit is contained in:
Oz Tiram 2019-04-05 08:20:57 +02:00
parent 18f45c9cec
commit 0779fc9c66
2 changed files with 10 additions and 4 deletions

View File

@ -75,7 +75,6 @@ class TestUtils(unittest.TestCase):
name="nginx-app", namespace="default",
body={})
def test_create_extensions_deployment_from_yaml(self):
"""
Should be able to create an extensions/v1beta1 deployment.

View File

@ -60,9 +60,16 @@ def create_from_yaml(
yml_document_all = yaml.safe_load_all(yaml_file)
# Load all documents from a single YAML file
fail_exceptions = []
for yml_document in yml_document_all:
create_from_dict(k8s_client, yml_document, verbose,
**kwargs)
exceptions = create_from_dict(k8s_client, yml_document, verbose,
**kwargs)
if exceptions:
fail_exceptions.extend(exceptions)
if fail_exceptions:
raise FailToCreateError(fail_exceptions)
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):
# In case we have exceptions waiting for us, raise them
if api_exceptions:
raise FailToCreateError(api_exceptions)
return api_exceptions
def create_from_yaml_single_item(