@@ -212,41 +212,54 @@ def load_meta_runtime(collection_name: str,
212212 return meta_runtime
213213
214214
215+ def _add_symlink_redirects (collection_name : str ,
216+ collection_metadata : AnsibleCollectionMetadata ,
217+ plugin_routing_out : t .Dict [str , t .Dict [str , t .Dict [str , t .Any ]]]
218+ ) -> None :
219+ for plugin_type in DOCUMENTABLE_PLUGINS :
220+ directory_name = 'modules' if plugin_type == 'module' else plugin_type
221+ directory_path = os .path .join (collection_metadata .path , 'plugins' , directory_name )
222+ plugin_type_routing = plugin_routing_out [plugin_type ]
223+
224+ symlink_redirects = find_symlink_redirects (collection_name , plugin_type , directory_path )
225+ for redirect_name , redirect_dst in symlink_redirects .items ():
226+ if redirect_name not in plugin_type_routing :
227+ plugin_type_routing [redirect_name ] = {}
228+ if 'redirect' not in plugin_type_routing [redirect_name ]:
229+ plugin_type_routing [redirect_name ]['redirect' ] = redirect_dst
230+ if plugin_type_routing [redirect_name ]['redirect' ] == redirect_dst :
231+ plugin_type_routing [redirect_name ]['redirect_is_symlink' ] = True
232+
233+
215234async def load_collection_routing (collection_name : str ,
216235 collection_metadata : AnsibleCollectionMetadata
217236 ) -> t .Dict [str , t .Dict [str , t .Dict [str , t .Any ]]]:
218237 """
219- Load plugin routing for a collection.
238+ Load plugin routing for a collection, and populate the private plugins lists
239+ in collection metadata.
220240 """
221241 meta_runtime = load_meta_runtime (collection_name , collection_metadata )
222242 plugin_routing_out : t .Dict [str , t .Dict [str , t .Dict [str , t .Any ]]] = {}
223243 plugin_routing_in = meta_runtime .get ('plugin_routing' ) or {}
244+ private_plugins : t .Dict [str , t .List [str ]] = {}
245+ collection_metadata .private_plugins = private_plugins
224246 for plugin_type in DOCUMENTABLE_PLUGINS :
225247 plugin_type_id = 'modules' if plugin_type == 'module' else plugin_type
226248 plugin_type_routing = plugin_routing_in .get (plugin_type_id ) or {}
227- plugin_routing_out [plugin_type ] = {
228- f'{ collection_name } .{ plugin_name } ' : process_dates (plugin_record )
229- for plugin_name , plugin_record in plugin_type_routing .items ()
230- }
249+ plugin_routing_out [plugin_type ] = {}
250+ private_plugins [plugin_type ] = []
251+ for plugin_name , plugin_record in plugin_type_routing .items ():
252+ fqcn = f'{ collection_name } .{ plugin_name } '
253+ plugin_routing_out [plugin_type ][fqcn ] = process_dates (plugin_record )
254+ if plugin_record .get ('private' , False ):
255+ private_plugins [plugin_type ].append (plugin_name )
231256
232257 if collection_name == 'ansible.builtin' :
233258 # ansible-core has a special directory structure we currently do not want
234259 # (or need) to handle
235260 return plugin_routing_out
236261
237- for plugin_type in DOCUMENTABLE_PLUGINS :
238- directory_name = 'modules' if plugin_type == 'module' else plugin_type
239- directory_path = os .path .join (collection_metadata .path , 'plugins' , directory_name )
240- plugin_type_routing = plugin_routing_out [plugin_type ]
241-
242- symlink_redirects = find_symlink_redirects (collection_name , plugin_type , directory_path )
243- for redirect_name , redirect_dst in symlink_redirects .items ():
244- if redirect_name not in plugin_type_routing :
245- plugin_type_routing [redirect_name ] = {}
246- if 'redirect' not in plugin_type_routing [redirect_name ]:
247- plugin_type_routing [redirect_name ]['redirect' ] = redirect_dst
248- if plugin_type_routing [redirect_name ]['redirect' ] == redirect_dst :
249- plugin_type_routing [redirect_name ]['redirect_is_symlink' ] = True
262+ _add_symlink_redirects (collection_name , collection_metadata , plugin_routing_out )
250263
251264 if collection_name in COLLECTIONS_WITH_FLATMAPPING :
252265 remove_flatmapping_artifacts (plugin_routing_out )
0 commit comments