Skip to content

Commit

Permalink
Migrations for corresponding change
Browse files Browse the repository at this point in the history
  • Loading branch information
djyasin committed Oct 22, 2024
1 parent 5a6a942 commit 1aece92
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 26 deletions.
6 changes: 3 additions & 3 deletions awx/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
)

from awx.main.utils.filters import SmartFilter
from awx.main.utils.plugins import return_inventory_source_options
from awx.main.utils.plugins import load_combined_inventory_source_options
from awx.main.utils.named_url_graph import reset_counters
from awx.main.scheduler.task_manager_models import TaskManagerModels
from awx.main.redact import UriCleaner, REPLACE_STR
Expand Down Expand Up @@ -2326,7 +2326,7 @@ class Meta:
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
if 'source' in self.fields:
self.fields['source'].choices = return_inventory_source_options() or {}
self.fields['source'].choices = load_combined_inventory_source_options()

def get_related(self, obj):
res = super(InventorySourceOptionsSerializer, self).get_related(obj)
Expand Down Expand Up @@ -5507,7 +5507,7 @@ def get_summary_fields(self, obj):
return summary_fields

def validate_unified_job_template(self, value):
if type(value) == InventorySource and value.source not in return_inventory_source_options():
if type(value) == InventorySource and value.source not in load_combined_inventory_source_options():
raise serializers.ValidationError(_('Inventory Source must be a cloud resource.'))
elif type(value) == Project and value.scm_type == '':
raise serializers.ValidationError(_('Manual Project cannot have a schedule set.'))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Generated by Django 4.2.10 on 2024-09-24 15:53
# Generated by Django 4.2.10 on 2024-10-22 15:58

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('main', '0195_EE_permissions'),
('main', '0197_remove_sso_app_content'),
]

operations = [
Expand Down
13 changes: 0 additions & 13 deletions awx/main/migrations/0198_merge_20241016_1759.py

This file was deleted.

20 changes: 12 additions & 8 deletions awx/main/utils/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@

@cache
def discover_available_cloud_provider_plugin_names() -> list[str]:
"""Return a list of cloud plugin names available in runtime.
"""
Return a list of cloud plugin names available in runtime.
The discovery result is cached since it does not change throughout
the life cycle of the server run.
Expand All @@ -29,7 +30,8 @@ def discover_available_cloud_provider_plugin_names() -> list[str]:

@cache
def compute_cloud_inventory_sources() -> dict[str, str]:
"""Return a dictionary of cloud provider plugin names
"""
Return a dictionary of cloud provider plugin names
available plus source control management and constructed.
:returns: Dictionary of plugin cloud names plus source control.
Expand All @@ -42,14 +44,16 @@ def compute_cloud_inventory_sources() -> dict[str, str]:


@cache
def return_inventory_source_options() -> dict[str, str]:
"""Return a dictionary of cloud provider plugin names
plus file. File needed to be separate since it is needs to be consumed directly
by the serializer.
def load_combined_inventory_source_options() -> dict[str, str]:
"""
Return a dictionary of cloud provider plugin names and 'file'.
:returns: Dictionary of plugin cloud names plus source control.
The 'file' entry is included separately since it needs to be consumed directly by the serializer.
:returns: A dictionary of cloud provider plugin names (as both keys and values) plus the 'file' entry.
:rtype: dict[str, str]
"""

plugins = compute_cloud_inventory_sources()

return dict(zip(plugins, plugins)) | dict(file='file')
return dict(zip(plugins, plugins), file='file')

0 comments on commit 1aece92

Please sign in to comment.