@@ -215,41 +215,54 @@ def load_meta_runtime(collection_name: str,
215215 return meta_runtime
216216
217217
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+
218237async def load_collection_routing (collection_name : str ,
219238 collection_metadata : AnsibleCollectionMetadata
220239 ) -> dict [str , dict [str , dict [str , t .Any ]]]:
221240 """
222- Load plugin routing for a collection.
241+ Load plugin routing for a collection, and populate the private plugins lists
242+ in collection metadata.
223243 """
224244 meta_runtime = load_meta_runtime (collection_name , collection_metadata )
225245 plugin_routing_out : dict [str , dict [str , dict [str , t .Any ]]] = {}
226246 plugin_routing_in = meta_runtime .get ('plugin_routing' ) or {}
247+ private_plugins : dict [str , list [str ]] = {}
248+ collection_metadata .private_plugins = private_plugins
227249 for plugin_type in DOCUMENTABLE_PLUGINS :
228250 plugin_type_id = 'modules' if plugin_type == 'module' else plugin_type
229251 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 )
234259
235260 if collection_name == 'ansible.builtin' :
236261 # ansible-core has a special directory structure we currently do not want
237262 # (or need) to handle
238263 return plugin_routing_out
239264
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 )
253266
254267 if collection_name in COLLECTIONS_WITH_FLATMAPPING :
255268 remove_flatmapping_artifacts (plugin_routing_out )
0 commit comments