@@ -215,41 +215,54 @@ def load_meta_runtime(collection_name: str,
215
215
return meta_runtime
216
216
217
217
218
+ def _add_symlink_redirects (collection_name : str ,
219
+ collection_metadata : AnsibleCollectionMetadata ,
220
+ plugin_routing_out : dict [str , dict [str , dict [str , t .Any ]]]
221
+ ) -> None :
222
+ for plugin_type in DOCUMENTABLE_PLUGINS :
223
+ directory_name = 'modules' if plugin_type == 'module' else plugin_type
224
+ directory_path = os .path .join (collection_metadata .path , 'plugins' , directory_name )
225
+ plugin_type_routing = plugin_routing_out [plugin_type ]
226
+
227
+ symlink_redirects = find_symlink_redirects (collection_name , plugin_type , directory_path )
228
+ for redirect_name , redirect_dst in symlink_redirects .items ():
229
+ if redirect_name not in plugin_type_routing :
230
+ plugin_type_routing [redirect_name ] = {}
231
+ if 'redirect' not in plugin_type_routing [redirect_name ]:
232
+ plugin_type_routing [redirect_name ]['redirect' ] = redirect_dst
233
+ if plugin_type_routing [redirect_name ]['redirect' ] == redirect_dst :
234
+ plugin_type_routing [redirect_name ]['redirect_is_symlink' ] = True
235
+
236
+
218
237
async def load_collection_routing (collection_name : str ,
219
238
collection_metadata : AnsibleCollectionMetadata
220
239
) -> dict [str , dict [str , dict [str , t .Any ]]]:
221
240
"""
222
- Load plugin routing for a collection.
241
+ Load plugin routing for a collection, and populate the private plugins lists
242
+ in collection metadata.
223
243
"""
224
244
meta_runtime = load_meta_runtime (collection_name , collection_metadata )
225
245
plugin_routing_out : dict [str , dict [str , dict [str , t .Any ]]] = {}
226
246
plugin_routing_in = meta_runtime .get ('plugin_routing' ) or {}
247
+ private_plugins : dict [str , list [str ]] = {}
248
+ collection_metadata .private_plugins = private_plugins
227
249
for plugin_type in DOCUMENTABLE_PLUGINS :
228
250
plugin_type_id = 'modules' if plugin_type == 'module' else plugin_type
229
251
plugin_type_routing = plugin_routing_in .get (plugin_type_id ) or {}
230
- plugin_routing_out [plugin_type ] = {
231
- f'{ collection_name } .{ plugin_name } ' : process_dates (plugin_record )
232
- for plugin_name , plugin_record in plugin_type_routing .items ()
233
- }
252
+ plugin_routing_out [plugin_type ] = {}
253
+ private_plugins [plugin_type ] = []
254
+ for plugin_name , plugin_record in plugin_type_routing .items ():
255
+ fqcn = f'{ collection_name } .{ plugin_name } '
256
+ plugin_routing_out [plugin_type ][fqcn ] = process_dates (plugin_record )
257
+ if plugin_record .get ('private' , False ):
258
+ private_plugins [plugin_type ].append (plugin_name )
234
259
235
260
if collection_name == 'ansible.builtin' :
236
261
# ansible-core has a special directory structure we currently do not want
237
262
# (or need) to handle
238
263
return plugin_routing_out
239
264
240
- for plugin_type in DOCUMENTABLE_PLUGINS :
241
- directory_name = 'modules' if plugin_type == 'module' else plugin_type
242
- directory_path = os .path .join (collection_metadata .path , 'plugins' , directory_name )
243
- plugin_type_routing = plugin_routing_out [plugin_type ]
244
-
245
- symlink_redirects = find_symlink_redirects (collection_name , plugin_type , directory_path )
246
- for redirect_name , redirect_dst in symlink_redirects .items ():
247
- if redirect_name not in plugin_type_routing :
248
- plugin_type_routing [redirect_name ] = {}
249
- if 'redirect' not in plugin_type_routing [redirect_name ]:
250
- plugin_type_routing [redirect_name ]['redirect' ] = redirect_dst
251
- if plugin_type_routing [redirect_name ]['redirect' ] == redirect_dst :
252
- plugin_type_routing [redirect_name ]['redirect_is_symlink' ] = True
265
+ _add_symlink_redirects (collection_name , collection_metadata , plugin_routing_out )
253
266
254
267
if collection_name in COLLECTIONS_WITH_FLATMAPPING :
255
268
remove_flatmapping_artifacts (plugin_routing_out )
0 commit comments