@@ -155,6 +155,30 @@ def check_completeness_of_list_of_hooks_sensors_hooks(yaml_files: Dict[str, Dict
155
155
sys .exit (1 )
156
156
157
157
158
+ def check_duplicates_in_integrations_names_of_hooks_sensors_operators (yaml_files : Dict [str , Dict ]):
159
+ print ("Checking for duplicates in list of {sensors, hooks, operators}" )
160
+ errors = []
161
+ for (yaml_file_path , provider_data ), resource_type in product (
162
+ yaml_files .items (), ["sensors" , "operators" , "hooks" ]
163
+ ):
164
+ resource_data = provider_data .get (resource_type , [])
165
+ current_integrations = [r .get ("integration-name" , "" ) for r in resource_data ]
166
+ if len (current_integrations ) != len (set (current_integrations )):
167
+ for integration in current_integrations :
168
+ if current_integrations .count (integration ) > 1 :
169
+ errors .append (
170
+ f"Duplicated content of '{ resource_type } /integration-name/{ integration } ' "
171
+ f"in file: { yaml_file_path } "
172
+ )
173
+
174
+ if errors :
175
+ print (f"Found { len (errors )} errors" )
176
+ for error in errors :
177
+ print (error )
178
+ print ()
179
+ sys .exit (1 )
180
+
181
+
158
182
def check_completeness_of_list_of_transfers (yaml_files : Dict [str , Dict ]):
159
183
print ("Checking completeness of list of transfers" )
160
184
errors = []
@@ -185,6 +209,35 @@ def check_completeness_of_list_of_transfers(yaml_files: Dict[str, Dict]):
185
209
sys .exit (1 )
186
210
187
211
212
+ def check_duplicates_in_list_of_transfers (yaml_files : Dict [str , Dict ]):
213
+ print ("Checking for duplicates in list of transfers" )
214
+ errors = []
215
+ resource_type = "transfers"
216
+ for yaml_file_path , provider_data in yaml_files .items ():
217
+ resource_data = provider_data .get (resource_type , [])
218
+
219
+ source_target_integrations = [
220
+ (r .get ("source-integration-name" , "" ), r .get ("target-integration-name" , "" ))
221
+ for r in resource_data
222
+ ]
223
+ if len (source_target_integrations ) != len (set (source_target_integrations )):
224
+ for integration_couple in source_target_integrations :
225
+ if source_target_integrations .count (integration_couple ) > 1 :
226
+ errors .append (
227
+ f"Duplicated content of \n "
228
+ f" '{ resource_type } /source-integration-name/{ integration_couple [0 ]} ' "
229
+ f" '{ resource_type } /target-integration-name/{ integration_couple [1 ]} ' "
230
+ f"in file: { yaml_file_path } "
231
+ )
232
+
233
+ if errors :
234
+ print (f"Found { len (errors )} errors" )
235
+ for error in errors :
236
+ print (error )
237
+ print ()
238
+ sys .exit (1 )
239
+
240
+
188
241
def check_invalid_integration (yaml_files : Dict [str , Dict ]):
189
242
print ("Detect unregistered integrations" )
190
243
errors = []
@@ -278,7 +331,10 @@ def check_doc_files(yaml_files: Dict[str, Dict]):
278
331
check_integration_duplicates (all_parsed_yaml_files )
279
332
280
333
check_completeness_of_list_of_hooks_sensors_hooks (all_parsed_yaml_files )
334
+ check_duplicates_in_integrations_names_of_hooks_sensors_operators (all_parsed_yaml_files )
335
+
281
336
check_completeness_of_list_of_transfers (all_parsed_yaml_files )
337
+ check_duplicates_in_list_of_transfers (all_parsed_yaml_files )
282
338
283
339
if all_files_loaded :
284
340
# Only check those if all provider files are loaded
0 commit comments