Add mirror command and API for selective package mirroring#40
Open
Add mirror command and API for selective package mirroring#40
Conversation
88c9419 to
17a0bbd
Compare
Add a `proxy mirror` CLI command and `/api/mirror` API endpoints that pre-populate the cache from various input sources: individual PURLs, SBOM files (CycloneDX and SPDX), or full registry enumeration. The mirror reuses the existing handler.Proxy.GetOrFetchArtifact() pipeline so cached artifacts are identical to those fetched on demand. A bounded worker pool controls download parallelism. Metadata caching is opt-in via `cache_metadata: true` in config (or PROXY_CACHE_METADATA=true). The mirror command always enables it. When enabled, upstream metadata responses are stored for offline fallback with ETag-based conditional revalidation. New internal/mirror package with Source interface, PURLSource, SBOMSource, RegistrySource, and async JobStore. New metadata_cache database table for offline metadata serving.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a
proxy mirrorCLI command and/api/mirrorREST endpoints for pre-populating the cache from multiple input sources.Input modes (narrowest to broadest):
proxy mirror pkg:npm/lodash@4.17.21proxy mirror pkg:npm/lodashproxy mirror --sbom sbom.cdx.json(CycloneDX JSON/XML, SPDX JSON/tag-value)proxy mirror --registry npm(stub, returns clear not-yet-implemented error)Architecture:
internal/mirror/package withSourceinterface and implementationshandler.Proxy.GetOrFetchArtifact()for fetch-and-cacheerrgroupwith--concurrencyflag (default 4)--dry-runflag to preview what would be mirroredmetadata_cachedatabase table for offline metadata servingAPI endpoints:
POST /api/mirror- start a mirror jobGET /api/mirror/{id}- check job statusDELETE /api/mirror/{id}- cancel a running jobNew dependencies:
github.com/CycloneDX/cyclonedx-go- CycloneDX SBOM parsinggithub.com/spdx/tools-golang- SPDX SBOM parsingRelated to #20.