Skip to content

cleanup: delete internal/cache in favor of oras-go/content/cache #2313

Done

Description

@TerryHowe

Follow-on to #2008 (phase 2.2). The v2→v3 migration (#2002) has merged; this is one of the remaining deprecation-cleanup items.

Problem

internal/cache/ (target.go + target_test.go, ~326 LOC) duplicates functionality that oras-go v3 now ships first-class as github.com/oras-project/oras-go/v3/content/cache.

The library package also reads ORAS_CACHE itself and backs the store with the process-safe oci.NewStorage():

// oras-go content/cache/cache.go
func NewFromEnv() *Cache                                              // reads ORAS_CACHE, nil if unset
func (c *Cache) ReadOnlyTarget(source oras.ReadOnlyTarget) (oras.ReadOnlyTarget, error)

Change

Reduce cmd/oras/internal/option/cache.go to a delegation to cache.NewFromEnv() / (*Cache).ReadOnlyTarget(), and delete internal/cache/.

Net ~−380 LOC.

Caveat to check before swapping

The library documents an interface narrowing:

Note: The returned target implements only oras.ReadOnlyTarget. If the source implements additional interfaces (e.g. registry.ReferenceFetcher), those methods are also cached, but type assertions for other interfaces may fail.

Audit every caller of option.Cache.CachedTarget for type assertions on registry.ReferenceFetcher, registry.ReferenceParser, registry.TagLister, etc. internal/cache/target.go builds explicit wrapper types for these combinations, so the narrowing is a real behavioural difference, not a doc formality.

Acceptance

  • internal/cache/ deleted
  • No caller of CachedTarget regresses on an interface assertion
  • Any scenario in internal/cache/target_test.go not already covered upstream is retained as regression coverage

Activity

  1. added this to the future milestone on Nov 4, 2026
  2. added
    enhancement
    go
    on Nov 4, 2026
  3. Avadhut03 commented on Nov 9, 2026

    @Avadhut03

    Hi @TerryHowe , I would like to work on this issue. Can you assign it to me?

  4. TerryHowe commented on Nov 9, 2026

    @TerryHowe
    MemberAuthor

    We don't assign issues on this project, but welcome PRs. I don't want to merge this change until after our next CLI release though because I want to minimize the changes to the next release, so you should expect it to take a while to mergge. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementgo

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions