Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions alws/schemas/repository_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class RepositoryUpdate(BaseModel):
export_path: typing.Optional[str] = None
pulp_href: typing.Optional[str] = None
mock_enabled: bool = True
url: typing.Optional[str] = None


class RepositorySync(BaseModel):
Expand Down
29 changes: 28 additions & 1 deletion scripts/bootstrap_repositories.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@ def parse_args():
required=False,
help="Do not sync repositories with " "corresponding remotes",
)
parser.add_argument(
"--use-remote-url",
action="store_true",
default=False,
required=False,
help="Use remote_url directly as the repository URL even for "
"production repos, skipping Pulp repo/remote creation and sync. "
"Intended for dev instances that should not sync from remotes.",
)
parser.add_argument(
"-c",
"--config",
Expand Down Expand Up @@ -261,6 +270,7 @@ async def process_repository(
repo_info: dict,
no_remotes: bool,
no_sync: bool,
use_remote_url: bool,
logger: logging.Logger,
):
"""Process a single repo: create repo + remote, return (id, sync_info)."""
Expand All @@ -270,6 +280,14 @@ async def process_repository(
repo_sync_policy = repo_info.pop("repository_sync_policy", None)
remote_sync_policy = repo_info.pop("remote_sync_policy", None)

if use_remote_url and is_production:
logger.info(
"use_remote_url is enabled; treating production repo %s as "
"non-production (remote_url used directly, no Pulp sync)",
repo_name,
)
is_production = False

repository = await get_repository(
pulp_client, repo_info, repo_name, is_production, logger
)
Expand Down Expand Up @@ -317,14 +335,20 @@ async def process_repositories(
repositories_data: list,
no_remotes: bool,
no_sync: bool,
use_remote_url: bool,
logger: logging.Logger,
):
sem = asyncio.Semaphore(BOOTSTRAP_CONCURRENCY)

async def bounded(repo_info):
async with sem:
return await process_repository(
pulp_client, repo_info, no_remotes, no_sync, logger
pulp_client,
repo_info,
no_remotes,
no_sync,
use_remote_url,
logger,
)

return await asyncio.gather(*(bounded(r) for r in repositories_data))
Expand Down Expand Up @@ -415,6 +439,8 @@ async def main_async():
platform_name,
)
for repo_id, repo_data in repos_to_update.items():
if args.use_remote_url and repo_data.get("remote_url"):
repo_data = {**repo_data, "url": repo_data["remote_url"]}
await update_repository(repo_id, repo_data)
logger.info(
"Updating repository data for platform %s is completed",
Expand All @@ -437,6 +463,7 @@ async def main_async():
repositories_data,
args.no_remotes,
args.no_sync,
args.use_remote_url,
logger,
)
repos_to_sync = []
Expand Down
Loading