Skip to content

Commit c4a9d30

Browse files
committed
Implement remote.Pusher
The Pusher handles multiplexing across multiple repositories and deduplicating in-flight uploads. This removes the need to do an awkward dance around re-using auth handshakes by passing custom transports. This also fixes limitations in remote.MultiWrite around streaming layers and multiple repositories.
1 parent 4a79e94 commit c4a9d30

File tree

5 files changed

+592
-258
lines changed

5 files changed

+592
-258
lines changed

pkg/v1/remote/descriptor.go

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ type Descriptor struct {
7373
platform v1.Platform
7474
}
7575

76+
func (d *Descriptor) toDesc() v1.Descriptor {
77+
return d.Descriptor
78+
}
79+
7680
// RawManifest exists to satisfy the Taggable interface.
7781
func (d *Descriptor) RawManifest() ([]byte, error) {
7882
return d.Manifest, nil
@@ -117,7 +121,11 @@ func get(ref name.Reference, acceptable []types.MediaType, options ...Option) (*
117121
if err != nil {
118122
return nil, err
119123
}
120-
b, desc, err := f.fetchManifest(o.context, ref, acceptable)
124+
return f.get(o.context, ref, acceptable)
125+
}
126+
127+
func (f *fetcher) get(ctx context.Context, ref name.Reference, acceptable []types.MediaType) (*Descriptor, error) {
128+
b, desc, err := f.fetchManifest(ctx, ref, acceptable)
121129
if err != nil {
122130
return nil, err
123131
}
@@ -126,7 +134,7 @@ func get(ref name.Reference, acceptable []types.MediaType, options ...Option) (*
126134
ref: ref,
127135
Manifest: b,
128136
Descriptor: *desc,
129-
platform: o.platform,
137+
platform: f.platform,
130138
}, nil
131139
}
132140

@@ -237,9 +245,11 @@ type resource interface {
237245

238246
// fetcher implements methods for reading from a registry.
239247
type fetcher struct {
240-
target resource
241-
client *http.Client
242-
context context.Context
248+
target resource
249+
client *http.Client
250+
context context.Context
251+
platform v1.Platform
252+
pageSize int
243253
}
244254

245255
func makeFetcher(ctx context.Context, target resource, o *options) (*fetcher, error) {
@@ -266,9 +276,11 @@ func makeFetcher(ctx context.Context, target resource, o *options) (*fetcher, er
266276
return nil, err
267277
}
268278
return &fetcher{
269-
target: target,
270-
client: &http.Client{Transport: tr},
271-
context: ctx,
279+
target: target,
280+
client: &http.Client{Transport: tr},
281+
context: ctx,
282+
platform: o.platform,
283+
pageSize: o.pageSize,
272284
}, nil
273285
}
274286

0 commit comments

Comments
 (0)