Add Homebrew JSON API and bottle proxy support - #254
Open
andrew wants to merge 2 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
Adds first-class proxying for Homebrew’s JSON API and homebrew/core OCI bottles, building on the existing metadata cache + OCI artifact store to support offline use while preserving signed API payload bytes and validating digest-addressed OCI content before caching.
Changes:
- Adds
/homebrew/*handler to proxy Homebrew JSON API responses (including signed JWS) with optional metadata caching. - Extends OCI
/v2/*routing to support per-repository upstream registries (used to sendhomebrew/coreto GHCR by default). - Adds digest verification for cached OCI blobs/manifests and expands validator handling (ETag/Last-Modified, HEAD behavior) across metadata + OCI manifest responses.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| README.md | Documents Homebrew client configuration and upstream chaining. |
| internal/server/server.go | Wires /homebrew routing and registers homebrew/core registry override for /v2. |
| internal/handler/homebrew.go | New Homebrew JSON API handler and homebrew/core OCI registry registration helper. |
| internal/handler/homebrew_test.go | Tests byte-for-byte signed response preservation, validators, offline stale serving, and path/method rejection. |
| internal/handler/handler.go | Improves validator usage, HEAD behavior, and adds artifact digest verification before caching. |
| internal/handler/handler_test.go | Updates mock storage hashing to SHA-256 to support new digest verification behavior. |
| internal/handler/container.go | Adds per-repository registry routing and digest verification for blob fetches; improves HEAD response header handling. |
| internal/handler/container_test.go | Adds tests for longest-prefix registry routing, credential non-forwarding, and digest mismatch non-caching. |
| internal/handler/container_manifest.go | Adds registry-scoped manifest cache keys, Last-Modified handling, conditional 304 support, and manifest digest verification. |
| internal/config/config.go | Adds configurable Homebrew API + artifact upstreams with defaults and env var support. |
| internal/config/config_test.go | Verifies defaults + YAML/env loading for new Homebrew upstream config. |
| docs/configuration.md | Documents new upstream config keys. |
| config.example.yaml | Adds example Homebrew upstream configuration entries. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
118
to
120
| h.proxy.Logger.Info("container blob request", "name", name, "digest", digest) | ||
| registryURL := h.registryURLFor(name) | ||
|
|
Comment on lines
190
to
+191
| h.proxy.Logger.Info("container manifest request", "name", name, "reference", reference) | ||
| h.serveManifest(w, r, name, reference) | ||
| h.serveManifest(w, r, h.registryURLFor(name), name, reference) |
Comment on lines
+55
to
+56
| accept := r.Header.Get("Accept") | ||
| h.proxy.ProxyCached(w, r, upstreamURL, homebrewMetadataEcosystem, homebrewMetadataCacheKey(requestPath, r.URL.RawQuery), accept) |
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 first-class Homebrew JSON API and bottle proxy support for #247.
Signed API responses are cached without rewriting.
homebrew/coremanifests and blobs are served offline from cache and checked against their content digests before cache records are written.The API and artifact upstreams default to
https://formulae.brew.sh/apiandhttps://ghcr.io. Both can be configured through YAML or environment variables, so one proxy can use another proxy as its upstream.Client setup and upstream configuration are documented in the README.
Closes #247