feat(RELEASE-1989): add Python implementation for publish-index-image#784
feat(RELEASE-1989): add Python implementation for publish-index-image#784midnightercz wants to merge 1 commit into
Conversation
Review Summary by QodoAdd Python implementation for publish-index-image with skopeo integration and comprehensive testing
WalkthroughsDescription• Implements managed and internal publish-index-image tasks with comprehensive skopeo integration for container image publishing • Adds SkopeoClient Python wrapper for skopeo CLI operations (inspect, copy) with error handling and credential support • Implements internal_request module for creating and managing Kubernetes InternalRequest custom resources with polling and timeout validation • Adds Pydantic models for Kubernetes InternalRequest resources with factory methods for loading from JSON/dict/file • Implements Secret class for secure credential handling with masking in logs and unveil() method for accessing actual values • Adds FakeSkopeoClient for testing without registry access, supporting YAML-based mock responses with regex matching • Includes comprehensive test coverage with 30+ test cases across all new modules (skopeo, internal_request, secret, managed/internal tasks) • Adds logger setup function with configurable handlers and async_in_executor() decorator for parallel execution • Updates Dockerfile and pyproject.toml for Python utils package installation and new dependencies (kubernetes, pydantic, jq) • Includes documentation for fake skopeo testing framework with configuration format and usage examples Diagramflowchart LR
IR["IR Results<br/>JSON"]
MPI["managed_publish<br/>_index_image"]
IPI["internal_publish<br/>_index_image"]
SK["SkopeoClient"]
KIR["Kubernetes<br/>InternalRequest"]
IR -- "extract component<br/>details" --> MPI
MPI -- "spawn parallel<br/>requests" --> KIR
MPI -- "monitor<br/>completion" --> KIR
KIR -- "trigger" --> IPI
IPI -- "copy images<br/>with credentials" --> SK
SK -- "inspect/copy<br/>operations" --> SK
File Changes1. scripts/python/helpers/internal_request.py
|
There was a problem hiding this comment.
Pull request overview
Introduces a Python implementation of the index-image publishing flow (managed task + internal task), together with supporting helpers (SkopeoClient and a FakeSkopeoClient, a Kubernetes-based internal_request module and Secret/InternalRequest rsmodels), an enhanced setup_logger, and the wiring needed to make these importable in tests and the container image.
Changes:
- Adds
managed_publish_index_image(spawns parallel InternalRequests via aProcessPoolExecutor) andpublish_index_image(skopeo-based idempotent copy). - Adds
skopeo.py,fake/skopeo.py,internal_request.py,rsmodels/secret.py,rsmodels/internal_request_models.py,decorators.py, and extendslogger.py. - Updates
Dockerfile,pyproject.toml, andPYTHONPATHto add the new dependencies (kubernetes,pydantic,jq), include themanagedtask tree, and install a local package.
Reviewed changes
Copilot reviewed 20 out of 24 changed files in this pull request and generated 15 comments.
Show a summary per file
| File | Description |
|---|---|
| pyproject.toml | Adds new deps, includes managed tasks in pythonpath, and configures a setuptools build pointing at utils/rsutils. |
| Dockerfile | Reorders COPY utils, copies README.md/pyproject.toml/uv.lock, and adds uv pip install .; extends PYTHONPATH. |
| scripts/python/helpers/logger.py | Adds setup_logger() returning a logger configured with stdout+stderr handlers. |
| scripts/python/helpers/decorators.py | Adds async_in_executor decorator wrapping a function with executor.submit. |
| scripts/python/helpers/skopeo.py | New SkopeoClient wrapper over the skopeo CLI with inspect/copy. |
| scripts/python/helpers/test_skopeo.py | Unit tests for SkopeoClient flag construction and error handling. |
| scripts/python/helpers/internal_request.py | Python port of the internal-request bash script using the Kubernetes client. |
| scripts/python/helpers/test_internal_request.py | Unit tests for payload building, parsing, create/get/wait. |
| scripts/python/helpers/rsmodels/secret.py | New Secret str subclass with masking + unveil. |
| scripts/python/helpers/test_secret.py | Tests for Secret masking, pickling, and unveil(). |
| scripts/python/helpers/rsmodels/internal_request_models.py | Pydantic models for the InternalRequest CR. |
| scripts/python/helpers/rsmodels/init.py | Package marker. |
| scripts/python/helpers/fake/skopeo.py | YAML-driven FakeSkopeoClient for tests. |
| scripts/python/helpers/fake/test_fake_skopeo.py | Tests for the fake skopeo matching and validation. |
| scripts/python/helpers/fake/init.py | Exports patch_skopeo_client() monkey-patch helper. |
| scripts/python/helpers/fake/FAKE_SKOPEO_README.md | Usage docs for the fake skopeo. |
| scripts/python/tasks/internal/publish_index_image.py | New internal task that copies an index image with digest-based dedup. |
| scripts/python/tasks/internal/test_publish_index_image.py | Unit tests for the internal task. |
| scripts/python/tasks/managed/managed_publish_index_image.py | New managed task orchestrating parallel IRs. |
| scripts/python/tasks/managed/init.py | Package marker. |
| scripts/python/tasks/managed/tests/init.py | Package marker. |
| scripts/python/tasks/managed/tests/test_managed_publish_index_image.py | Tests for the managed task using fixtures. |
| scripts/python/tasks/managed/tests/irs.py | Sample InternalRequest dictionaries used by the managed tests. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
fe57a7e to
2ec6cd7
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #784 +/- ##
==========================================
+ Coverage 94.18% 94.97% +0.79%
==========================================
Files 38 46 +8
Lines 3009 3841 +832
==========================================
+ Hits 2834 3648 +814
- Misses 175 193 +18
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
75d61f5 to
b98da23
Compare
b98da23 to
08d8a4d
Compare
|
Can you update the commit to use Assisted-by: instead of Co-Authored-By: Claude Sonnet 4.5 noreply@anthropic.com ? So the label AI CI will work. |
08d8a4d to
30b1ea9
Compare
fixed |
6176c9b to
ff0c69c
Compare
d957221 to
80faf77
Compare
f792f3c to
4b514ec
Compare
Implements managed and internal publish-index-image tasks with comprehensive skopeo integration and testing infrastructure: - Add managed_publish_index_image task that processes IR results and spawns parallel internal Tekton requests for image publishing - Add internal publish_index_image task that copies index images using skopeo - Implement skopeo wrapper module with inspect, copy, and login operations - Add internal_request module for creating and managing Tekton internal requests - Implement rsmodels for internal request and secret data models - Add fake skopeo implementation for testing without registry access - Include comprehensive test coverage for all new modules - Update Dockerfile and dependencies for Python task execution Assisted-by: claude Signed-off-by: Jindrich Luza <jluza@redhat.com>
4b514ec to
2f79472
Compare
| @@ -0,0 +1,354 @@ | |||
| """Python client for skopeo container image operations.""" | |||
There was a problem hiding this comment.
Should we perhaps create a separate PR for the skopeo helper and prioritize the review? This implementation looks the most promising from a first glance, so it would be nice if we could have this sooner rather than later, since there's a lot of tasks which use this tool.
There was a problem hiding this comment.
#812. I'm going to be on PTO for next 2 weeks. So feel free to merge the PR
seanconroy2021
left a comment
There was a problem hiding this comment.
LGTM - Once Fitz's comment is resolved :)
… tasks
Implements managed and internal publish-index-image tasks with comprehensive skopeo integration and testing infrastructure: