Repository navigation
cleanup: use oras-go content/cache for ORAS_CACHE - #2330
Merged
TerryHowe merged 1 commit intoNov 24, 2026
Merged
Conversation
oras-go v3 ships content/cache, which reads ORAS_CACHE, stores content with the process-safe oci.NewStorage and keeps the source's ReferenceFetcher, ReferenceParser and ReferrerLister interfaces. internal/cache duplicated it and only kept ReferenceFetcher. Reduce option.Cache.CachedTarget to a delegation and delete internal/cache. Every caller (pull, blob fetch, manifest fetch, manifest fetch-config) only passes the target to oras.Resolve/Fetch/ FetchBytes/Copy and content.FetchAll, so no interface assertion regresses. A new test asserts the cached target still implements registry.ReferenceFetcher. Behaviour change: FetchReference now resolves the tag first and serves cached content on a hit (one extra HEAD on a miss); the old wrapper always fetched references from the source. Fixes oras-project#2313 Signed-off-by: Shravanth Reddy <[email protected]>
ShravanthReddy
requested review from
TerryHowe,
Wwwsylvia,
sabre1041,
sajayantony and
shizhMSFT
as code owners
November 11, 2026 19:12
Member
|
Looks good. I'd like to deliver this after the next release though. |
TerryHowe
reviewed
Nov 24, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2330 +/- ##
==========================================
+ Coverage 73.51% 73.61% +0.09%
==========================================
Files 157 156 -1
Lines 6582 6519 -63
==========================================
- Hits 4839 4799 -40
+ Misses 1454 1440 -14
+ Partials 289 280 -9 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
What this PR does / why we need it:
Builds on #2329.
option.Cache.CachedTargetnow delegates to oras-go'scontent/cache(cache.NewFromEnv()/(*Cache).ReadOnlyTarget()), andinternal/cache/is deleted (−440 / +81 lines, most of the additions being tests). The library readsORAS_CACHEand stores content with the process-safeoci.NewStorage(), as #2329 does today.Interface audit:
CacheReadOnlyTargetkeepsregistry.ReferenceFetcher,ReferenceParserandReferrerListerwhen the source has them. That's a superset of the old wrapper, which only keptReferenceFetcher.pull,blob fetch,manifest fetch,manifest fetch-config) only pass the target tooras.Resolve/Fetch/FetchBytes/Copyandcontent.FetchAll, so no type assertion can regress.TestCache_CachedTarget_keepsReferenceFetcherasserts the interface throughCachedTarget.Behaviour change worth a look:
FetchReferencenow resolves the tag with a HEAD first and serves cached content on a hit. That's one extra HEAD on a miss and no body download on a hit. The old wrapper always fetched references from the source. The new test pins this: the source'sFetchReferenceis called once for two fetches.Coverage:
internal/cache/target_test.gohad three tests.fetchCacheandfetchReferenceare covered upstream (TestTarget_Fetch*,TestReferenceTarget_FetchReference*).pushPassThroughexercised an anonymous struct overmemory.Storerather than the cache, so nothing is lost. #2329's tests are kept as they are.Small doc note for oras-go, separately:
Cache.ReadOnlyTarget's comment still says type assertions "may fail", butCacheReadOnlyTargetnow keeps those interfaces.go test -race ./...passes, golangci-lint is clean andgo mod tidyleaves no diff.Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)format, will close the issue(s) when PR gets merged):Fixes #2313. Happy to hand off or close if @Avadhut03 already has work in progress; fine to hold this until after the next CLI release.
Please check the following list: