Skip to content

Commit

Permalink
internal/urlutil: remove unnecessary copy to memory
Browse files Browse the repository at this point in the history
  • Loading branch information
jroimartin committed Dec 1, 2023
1 parent 4bd7182 commit ff3be14
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions internal/urlutil/urlutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"oras.land/oras-go/v2"
"oras.land/oras-go/v2/content"
"oras.land/oras-go/v2/content/memory"
"oras.land/oras-go/v2/registry/remote"
)

Expand Down Expand Up @@ -94,14 +93,12 @@ func getOCI(u *url.URL) ([]byte, error) {
}
src.PlainHTTP = ociPlainHTTP

dst := memory.New()

desc, err := oras.Copy(context.Background(), src, tag, dst, tag, oras.DefaultCopyOptions)
desc, err := oras.Resolve(context.Background(), src, tag, oras.DefaultResolveOptions)
if err != nil {
return nil, fmt.Errorf("artifact copy: %w", err)
return nil, fmt.Errorf("resolve: %w", err)
}

successors, err := content.Successors(context.Background(), dst, desc)
successors, err := content.Successors(context.Background(), src, desc)
if err != nil {
return nil, fmt.Errorf("artifact successors: %w", err)
}
Expand All @@ -114,7 +111,7 @@ func getOCI(u *url.URL) ([]byte, error) {
continue
}

data, err := content.FetchAll(context.Background(), dst, s)
data, err := content.FetchAll(context.Background(), src, s)
if err != nil {
return nil, fmt.Errorf("artifact fetch: %w", err)
}
Expand Down

0 comments on commit ff3be14

Please sign in to comment.