diff --git a/galaxy_ng/app/dynaconf_hooks.py b/galaxy_ng/app/dynaconf_hooks.py index 5e4ee561b9..e6390fd911 100755 --- a/galaxy_ng/app/dynaconf_hooks.py +++ b/galaxy_ng/app/dynaconf_hooks.py @@ -40,6 +40,7 @@ def post(settings: Dynaconf) -> Dict[str, Any]: data.update(configure_password_validators(settings)) data.update(configure_api_base_path(settings)) data.update(configure_legacy_roles(settings)) + data.update(configure_dab_resource_registry(settings)) # This should go last, and it needs to receive the data from the previous configuration # functions because this function configures the rest framework auth classes based off @@ -55,6 +56,17 @@ def post(settings: Dynaconf) -> Dict[str, Any]: return data +def configure_dab_resource_registry(settings: Dynaconf) -> Dict[str, Any]: + flags = settings.get("GALAXY_FEATURE_FLAGS") + + data = {} + if flags["dab_resource_registry"]: + data["INSTALLED_APPS"] = ['ansible_base.resource_registry', 'dynaconf_merge'] + data["ANSIBLE_BASE_RESOURCE_CONFIG_MODULE"] = "galaxy_ng.app.api.resource_api" + + return data + + def configure_keycloak(settings: Dynaconf) -> Dict[str, Any]: """Configure keycloak settings for galaxy. diff --git a/galaxy_ng/app/settings.py b/galaxy_ng/app/settings.py index 17b0bef1e5..57dfc83449 100644 --- a/galaxy_ng/app/settings.py +++ b/galaxy_ng/app/settings.py @@ -22,7 +22,6 @@ INSTALLED_APPS = [ 'rest_framework.authtoken', - 'ansible_base.resource_registry', 'dynaconf_merge', ] @@ -102,6 +101,7 @@ 'execution_environments': True, # False will make execution_environments endpoints 404 'legacy_roles': False, 'ai_deny_index': False, # False will make _ui/v1/ai_deny_index/ to 404 + 'dab_resource_registry': False, } AUTH_PASSWORD_VALIDATORS = [ @@ -298,7 +298,6 @@ GALAXY_DYNAMIC_SETTINGS = False # DJANGO ANSIBLE BASE RESOURCES REGISTRY SETTINGS -ANSIBLE_BASE_RESOURCE_CONFIG_MODULE = "galaxy_ng.app.api.resource_api" ANSIBLE_BASE_ORGANIZATION_MODEL = "galaxy.Organization" # WARNING: This setting is used in database migrations to create a default organization. diff --git a/galaxy_ng/app/urls.py b/galaxy_ng/app/urls.py index 05dbdf94f0..9c83a57c0e 100644 --- a/galaxy_ng/app/urls.py +++ b/galaxy_ng/app/urls.py @@ -7,10 +7,6 @@ from galaxy_ng.app.api import urls as api_urls from galaxy_ng.ui import urls as ui_urls -from ansible_base.resource_registry.urls import ( - urlpatterns as resource_api_urls, -) - from drf_spectacular.views import ( SpectacularJSONAPIView, SpectacularYAMLAPIView, @@ -49,21 +45,24 @@ name="swagger-ui", ), path("healthz", views.health_view), - path(f"{API_PATH_PREFIX}", include(resource_api_urls)) ] +if settings["GALAXY_FEATURE_FLAGS"]["dab_resource_registry"]: + from ansible_base.resource_registry.urls import ( + urlpatterns as resource_api_urls, + ) + urlpatterns.append(path(f"{API_PATH_PREFIX}/", include(resource_api_urls))) + if settings.get("API_ROOT") != "/pulp/": urlpatterns.append( - path( - "pulp/api/", - views.PulpAPIRedirectView.as_view(), - name="pulp_redirect") + path("pulp/api/", views.PulpAPIRedirectView.as_view(), name="pulp_redirect") ) if settings.get("SOCIAL_AUTH_KEYCLOAK_KEY"): urlpatterns.append(url("", include("social_django.urls", namespace="social"))) - urlpatterns.append(path("login/", - lambda request: redirect("/login/keycloak/", permanent=False))) + urlpatterns.append( + path("login/", lambda request: redirect("/login/keycloak/", permanent=False)) + ) if settings.get("SOCIAL_AUTH_GITHUB_KEY"): - urlpatterns.append(url('', include('social_django.urls', namespace='github'))) + urlpatterns.append(url("", include("social_django.urls", namespace="github"))) diff --git a/profiles/dab/pulp_config.env b/profiles/dab/pulp_config.env index 3566231d12..6641c3b9c5 100644 --- a/profiles/dab/pulp_config.env +++ b/profiles/dab/pulp_config.env @@ -3,3 +3,5 @@ PULP_GALAXY_AUTHENTICATION_CLASSES="['ansible_base.jwt_consumer.hub.auth.HubJWTA PULP_ANSIBLE_BASE_JWT_VALIDATE_CERT=false PULP_ANSIBLE_BASE_JWT_KEY=https://localhost PULP_CSRF_TRUSTED_ORIGINS = ['https://localhost'] + +PULP_GALAXY_FEATURE_FLAGS__dab_resource_registry=true \ No newline at end of file