Skip to content

Commit d92e325

Browse files
committed
Utilize url from ANSIBLE_BASE_JWT_KEY to make Galaxy aware of the RESOURCE_PROVIDER
AAP-20998 No-Issue
1 parent e4b7a19 commit d92e325

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

galaxy_ng/app/dynaconf_hooks.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import os
66
import re
77
from typing import Any, Dict, List
8+
from urllib.parse import urlparse, urlunparse
89
from django_auth_ldap.config import LDAPSearch
910
from dynaconf import Dynaconf, Validator
1011
from galaxy_ng.app.dynamic_settings import DYNAMIC_SETTINGS_SCHEMA
@@ -41,6 +42,7 @@ def post(settings: Dynaconf) -> Dict[str, Any]:
4142
data.update(configure_api_base_path(settings))
4243
data.update(configure_legacy_roles(settings))
4344
data.update(configure_dab_resource_registry(settings))
45+
data.update(configure_resource_provider(settings))
4446

4547
# This should go last, and it needs to receive the data from the previous configuration
4648
# functions because this function configures the rest framework auth classes based off
@@ -582,6 +584,28 @@ def configure_legacy_roles(settings: Dynaconf) -> Dict[str, Any]:
582584
return data
583585

584586

587+
def configure_resource_provider(settings: Dynaconf) -> Dict[str, Any]:
588+
# The following variable is either a URL or a key file path.
589+
ANSIBLE_BASE_JWT_KEY = settings.get("ANSIBLE_BASE_JWT_KEY")
590+
if ANSIBLE_BASE_JWT_KEY:
591+
data = {
592+
"ANSIBLE_API_HOSTNAME": settings.get("ANSIBLE_API_HOSTNAME"),
593+
"ANSIBLE_CONTENT_HOSTNAME": settings.get("ANSIBLE_CONTENT_HOSTNAME"),
594+
}
595+
gw_url = urlparse(ANSIBLE_BASE_JWT_KEY)
596+
if gw_url.scheme and gw_url.hostname:
597+
for k in data:
598+
k_parsed = urlparse(data[k])
599+
if gw_url.scheme and gw_url.hostname:
600+
k_updated = k_parsed._replace(
601+
scheme=gw_url.scheme,
602+
netloc=gw_url.netloc,
603+
)
604+
data.update({k: urlunparse(k_updated)})
605+
return data
606+
return {}
607+
608+
585609
def validate(settings: Dynaconf) -> None:
586610
"""Validate the configuration, raise ValidationError if invalid"""
587611
settings.validators.register(

0 commit comments

Comments
 (0)