Repository navigation
Conversation
The Swift registry rewrites, the source archive lookup in release metadata, the checksum helpers and the package identifier checks move from internal/handler into internal/metadata/swift, which takes the proxy and upstream URLs explicitly and builds for wasip1. The handler keeps fetching, caching, routes and downloads, with its functions as thin wrappers.
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 40 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
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.
Part of #501, the Swift step.
As in #612 for npm, the Swift Package Registry metadata transformations move out of
internal/handlerintointernal/metadata/swift:RewriteLinkHeaderandRewriteRegistryURL, which point upstream URLs in aLinkheader at the proxy's/swiftpath and leave other hosts, schemes and paths outside the upstream as they areRewriteReleaseURLsandReleaseURL, for the release list'surlfieldsSourceArchiveandArchiveInfo, which read the source archive's checksum and signature from a release's metadataNormalizeChecksumandDigestHeaderValidScope,ValidPackageName,ValidPackageReferenceandCanonicalPackage, the identifier checks the routes useSwift has no cooldown filtering, so
Optionsonly carries the proxy and upstream URLs. The package doesn't depend onhandler.Proxy. The code moves as it was, so responses are the same.What stays in the handler: fetching, the metadata cache, routes, the source archive HEAD probe and headers, and downloads. The functions the handler and its tests use stay as thin wrappers, so the handler tests run unchanged against the real routes.
Portability:
GOOS=wasip1 GOARCH=wasm go build ./internal/metadata/swiftworks. The package imports only the standard library;imports_test.gofails on any non-standard import and onnet,net/http,log/slogordatabase/sql.New tests in
internal/metadata/swiftcover the URL rewrite for relative URLs, query, fragment, host case, other hosts and schemes, paths outside the upstream and unparseable input; the Link header; the release list; source archive lookup, signing and its errors; the checksum helpers; and the identifier rules including length limits. They were mutation-checked, as was the handler's wiring. There are no Swift benchmarks to compare.go test ./...andgolangci-lint run ./...pass.