Skip to content

Commit

Permalink
Fix collection of execptions when applying yaml
Browse files Browse the repository at this point in the history
 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.
  • Loading branch information
oz123 committed Apr 5, 2019
1 parent 18f45c9 commit 0779fc9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
1 change: 0 additions & 1 deletion kubernetes/e2e_test/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ def test_create_apps_deployment_from_yaml_obj(self):
name="nginx-app", namespace="default",
body={})


def test_create_extensions_deployment_from_yaml(self):
"""
Should be able to create an extensions/v1beta1 deployment.
Expand Down
13 changes: 10 additions & 3 deletions kubernetes/utils/create_from_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 0779fc9

Please sign in to comment.