Skip to content

Commit

Permalink
Add function to extract plugin name descriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
djyasin committed Nov 21, 2024
1 parent 7ddd9e3 commit 595b425
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion awx/main/utils/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,24 @@ def compute_cloud_inventory_sources() -> dict[str, str]:
return dict(zip(plugins, plugins), scm='scm', constructed='constructed')


@cache
def discover_available_cloud_provider_descriptions() -> dict[str, str]:
"""
Return a dictionary of cloud provider plugin descriptions
available.
:returns: Dictionary of plugin cloud descriptions.
:rtype: dict[str, str]
"""
from awx.main.models.inventory import InventorySourceOptions

plugin_description_list = [(plugin_name, plugin.plugin_description) for plugin_name, plugin in InventorySourceOptions.injectors.items()]

plugin_description = dict(plugin_description_list)

return plugin_description


@cache
def load_combined_inventory_source_options() -> dict[str, str]:
"""
Expand All @@ -56,7 +74,9 @@ def load_combined_inventory_source_options() -> dict[str, str]:

plugins = compute_cloud_inventory_sources()

result = {plugin: plugin.plugin_description for plugin in plugins}
plugin_description = discover_available_cloud_provider_descriptions()

result = {plugin: plugin_description.get(plugin, plugin) for plugin in plugins}

result['file'] = 'File-based inventory source'

Expand Down

0 comments on commit 595b425

Please sign in to comment.