Skip to content

Commit abfead8

Browse files
alacukuloresuso
authored andcommitted
fix(pusher): retrieve only the index and not all the layers
Fetch only the index data instead of the full graph pointed by the index which is what the copy function in ORAS does. Using the FetchReference function instead. Signed-off-by: Aldo Lacuku <[email protected]> Co-authored-by: Lorenzo Susini <[email protected]>
1 parent f08acf9 commit abfead8

File tree

1 file changed

+1
-8
lines changed

1 file changed

+1
-8
lines changed

pkg/oci/pusher/pusher.go

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ import (
3030
logger "github.com/sirupsen/logrus"
3131
"oras.land/oras-go/v2"
3232
"oras.land/oras-go/v2/content/file"
33-
"oras.land/oras-go/v2/content/memory"
3433
"oras.land/oras-go/v2/registry/remote"
3534
"oras.land/oras-go/v2/registry/remote/auth"
3635

@@ -112,9 +111,8 @@ func (p *Pusher) retrieveIndex(ctx context.Context, repo *remote.Repository) (*v
112111
var indexBytes []byte
113112
var index v1.Index
114113

115-
memoryStore := memory.New()
116114
ref := repo.Reference.String()
117-
indexDesc, err := oras.Copy(ctx, repo, repo.Reference.Reference, memoryStore, "", oras.DefaultCopyOptions)
115+
indexDesc, reader, err := repo.FetchReference(ctx, repo.Reference.Reference)
118116
if err != nil {
119117
if strings.Contains(err.Error(), fmt.Sprintf("%s: not found", repo.Reference.Reference)) {
120118
return nil, fmt.Errorf("unable to download image index for ref %s, %w", ref, ErrNotFound)
@@ -128,11 +126,6 @@ func (p *Pusher) retrieveIndex(ctx context.Context, repo *remote.Repository) (*v
128126
ref, indexDesc.MediaType, v1.MediaTypeImageIndex)
129127
}
130128

131-
reader, err := memoryStore.Fetch(ctx, indexDesc)
132-
if err != nil {
133-
return nil, fmt.Errorf("unable to fetch index from memory store for ref %q: %w", ref, err)
134-
}
135-
136129
if indexBytes, err = io.ReadAll(reader); err != nil {
137130
return nil, fmt.Errorf("unable to read index from reader for ref %q: %w", ref, err)
138131
}

0 commit comments

Comments
 (0)