Refactor into submodules #19
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Refactor the codebase into submodules.
E.g.
cache.redis
database.postgres
remote.{helm,npm,python,rpm,generic}
There should be no function change with this refactor
Resolution
Refactored the flat module structure into proper subpackages with no functional changes.
Changes made:
cache/redis.py— RedisCache moved from cache.py; cache/__init__.py re-exports it for backwards compatibilitydatabase/postgres.py— DatabaseManager moved from database.py; database/__init__.py re-exports itremote/base.py— get_content_type() extracted from main.pyremote/python.py— PyPI URL construction and HTML rewritingremote/npm.py— npm metadata URL rewritingremote/helm.py— Helm index.yaml URL rewritingremote/rpm.py— RPM remote (uses base content type; mutable patterns remain in config.py)remote/generic.py— generic HTTP remotesHow main.py was updated: _resolve_content() and construct_remote_url() now delegate to the relevant remote.* submodule instead of containing inline per-package logic. _get_content_type() removed from main.py.
All 187 existing tests pass. README updated with a code layout diagram.
Potential future improvements:
Additional refactor: storage/s3, auth/docker, and artifact/ handler split
storage/s3.py — S3Storage moved from storage.py. storage/__init__.py re-exports for backwards compat.
auth/docker.py — Docker Bearer token logic moved from docker_auth.py. docker_auth.py kept as a thin shim (re-exports all public symbols including _token_cache) so existing tests and import paths continue to work.
artifact/ subpackage — All route handler logic extracted from main.py. Each @app.route() in main.py is now a single-line delegation:
Tests updated to patch helpers at their new locations (artifactapi.artifact.proxy.*).
Wheel build confirmed with uv build. Docker stack (make docker-up) starts clean; /health, /, /v2/ all respond correctly.