Skip to content

Commit

Permalink
Allow specifying arch which overrides $basearch
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanspw committed Sep 25, 2024
1 parent 0d676bc commit e48eb48
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/backend/api/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,8 @@ def get_mirrors_list(
mirror.mirror_url + '/',
f'{version}/{repo_path}',
)
if arch:
full_mirror_path = full_mirror_path.replace('$basearch', arch)
mirrors_list.append(full_mirror_path)
if not from_cache:
cache.set(redis_key, nearest_mirrors, CACHE_EXPIRED_TIME)
Expand Down
16 changes: 15 additions & 1 deletion src/backend/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,18 +151,32 @@ def get_mirror_list(
version: str,
repository: str
):
# protocol get arg
request_protocol = request.args.get('protocol')
if request_protocol and request_protocol not in ["http","https"]:
return "Invalid input for protocol, valid options: http, https"
# country get arg
request_country = request.args.get('country')
if request_country and len(request_country) != 2:
return "Invalid input for country, valid options are 2 letter country codes"
# arch get arg
request_arch = request.args.get('arch')
if request_arch:
config = get_config(
logger=logger,
path_to_config=SERVICE_CONFIG_PATH,
path_to_json_schema=SERVICE_CONFIG_JSON_SCHEMA_DIR_PATH,
)
if not request_arch in config.arches:
arches = ' '.join(config.arches)
return f"Invalid arch requested, valid options are {arches}"

ip_address = _get_request_ip()

mirrors = get_mirrors_list(
ip_address=ip_address,
version=version,
arch=None,
arch=request_arch,
repository=repository,
request_protocol=request_protocol,
request_country=request_country,
Expand Down

0 comments on commit e48eb48

Please sign in to comment.