@@ -75,17 +75,10 @@ def create_from_yaml(
75
75
yaml_file = StringIO (content .decode ('utf-8' ))
76
76
77
77
yml_document_all = yaml .safe_load_all (yaml_file )
78
- # Load all documents from a single YAML file
79
- fail_exceptions = []
80
78
81
79
for yml_document in yml_document_all :
82
- exceptions = create_from_dict (k8s_client , yml_document , verbose ,
83
- ** kwargs )
84
- if exceptions :
85
- fail_exceptions .extend (exceptions )
86
-
87
- if fail_exceptions :
88
- raise FailToCreateError (fail_exceptions )
80
+ create_from_dict (k8s_client , yml_document , verbose ,
81
+ ** kwargs )
89
82
90
83
91
84
def create_from_dict (k8s_client , data , verbose = False , ** kwargs ):
@@ -99,10 +92,9 @@ def create_from_dict(k8s_client, data, verbose=False, **kwargs):
99
92
verbose: If True, print confirmation from the create action.
100
93
Default is False.
101
94
102
- Returns:
103
- A list of `client.rest.ApiException` instances for each object that
104
- failed to create. The user of this function can throw discard them.
105
-
95
+ Raises:
96
+ FailToCreateError which holds list of `client.rest.ApiException`
97
+ instances for each object that failed to create.
106
98
"""
107
99
# If it is a list type, will need to iterate its items
108
100
api_exceptions = []
@@ -132,7 +124,7 @@ def create_from_dict(k8s_client, data, verbose=False, **kwargs):
132
124
133
125
# In case we have exceptions waiting for us, raise them
134
126
if api_exceptions :
135
- return api_exceptions
127
+ raise FailToCreateError ( api_exceptions )
136
128
137
129
138
130
def create_from_yaml_single_item (
0 commit comments