Skip to content

Commit

Permalink
fixed the dynaconf transalation for ipv4 to ipv6
Browse files Browse the repository at this point in the history
  • Loading branch information
omkarkhatavkar committed Oct 10, 2024
1 parent b56eacd commit e9cd808
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions robottelo/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,29 @@
# dynaconf robottelo file uses ROBOTELLO_DIR for screenshots
os.environ['ROBOTTELO_DIR'] = str(robottelo_root_dir)

def replace_ipv4_with_ipv6_in_urls(settings):
def replace_in_value(value):
# Only replace 'ipv4' with 'ipv6' in strings that contain 'redhat.com'
if isinstance(value, str) and 'ipv4' in value and 'redhat.com' in value:
return value.replace('ipv4', 'ipv6')
return value

def resolve_and_replace(settings_dict):
resolved = {}
for key, value in settings_dict.items():
if isinstance(value, str):
resolved[key] = replace_in_value(value)
elif isinstance(value, dict):
# Recursively handle nested dictionaries
resolved[key] = resolve_and_replace(value)
else:
resolved[key] = value
return resolved

# Update the settings in-place with resolved and replaced values
updated_settings = resolve_and_replace(settings.as_dict())
for key, value in updated_settings.items():
settings.set(key, value)

def get_settings():
"""Return Lazy settings object after validating
Expand Down Expand Up @@ -49,6 +72,7 @@ def get_settings():


settings = get_settings()
replace_ipv4_with_ipv6_in_urls(settings)
robottelo_tmp_dir = Path(settings.robottelo.tmp_dir)
robottelo_tmp_dir.mkdir(parents=True, exist_ok=True)

Expand Down

0 comments on commit e9cd808

Please sign in to comment.