@@ -24,7 +24,7 @@ import (
24
24
"github.com/google/go-containerregistry/pkg/name"
25
25
v1 "github.com/google/go-containerregistry/pkg/v1"
26
26
"github.com/google/go-containerregistry/pkg/v1/partial"
27
- "github.com/google/go-containerregistry/pkg/v1/remote "
27
+ "github.com/google/go-containerregistry/pkg/v1/sourcesink "
28
28
"github.com/google/go-containerregistry/pkg/v1/stream"
29
29
"github.com/google/go-containerregistry/pkg/v1/types"
30
30
specsv1 "github.com/opencontainers/image-spec/specs-go/v1"
@@ -89,18 +89,16 @@ func unpackTaggable(t partial.WithRawManifest) ([]byte, *v1.Descriptor, error) {
89
89
}, nil
90
90
}
91
91
92
- // Use partial.Artifact to unpack taggable.
93
- // Duplication is not a concern here.
94
- type pusher struct {
92
+ type sink struct {
95
93
path Path
96
94
}
97
95
98
96
// Delete implements remote.Pusher.
99
- func (lp * pusher ) Delete (_ context.Context , _ name.Reference ) error {
97
+ func (lp * sink ) Delete (_ context.Context , _ name.Reference ) error {
100
98
return errors .New ("unsupported operation" )
101
99
}
102
100
103
- func (lp * pusher ) writeLayer (l v1.Layer ) error {
101
+ func (lp * sink ) writeLayer (l v1.Layer ) error {
104
102
dg , err := l .Digest ()
105
103
if err != nil {
106
104
return err
@@ -116,7 +114,7 @@ func (lp *pusher) writeLayer(l v1.Layer) error {
116
114
return nil
117
115
}
118
116
119
- func (lp * pusher ) writeLayers (pctx context.Context , img v1.Image ) error {
117
+ func (lp * sink ) writeLayers (pctx context.Context , img v1.Image ) error {
120
118
ls , err := img .Layers ()
121
119
if err != nil {
122
120
return err
@@ -155,7 +153,7 @@ func (lp *pusher) writeLayers(pctx context.Context, img v1.Image) error {
155
153
return g .Wait ()
156
154
}
157
155
158
- func (lp * pusher ) writeChildren (pctx context.Context , idx v1.ImageIndex ) error {
156
+ func (lp * sink ) writeChildren (pctx context.Context , idx v1.ImageIndex ) error {
159
157
children , err := partial .Manifests (idx )
160
158
if err != nil {
161
159
return err
@@ -173,7 +171,7 @@ func (lp *pusher) writeChildren(pctx context.Context, idx v1.ImageIndex) error {
173
171
return g .Wait ()
174
172
}
175
173
176
- func (lp * pusher ) writeDeps (ctx context.Context , m partial.Artifact ) error {
174
+ func (lp * sink ) writeDeps (ctx context.Context , m partial.Artifact ) error {
177
175
if img , ok := m .(v1.Image ); ok {
178
176
return lp .writeLayers (ctx , img )
179
177
}
@@ -186,7 +184,7 @@ func (lp *pusher) writeDeps(ctx context.Context, m partial.Artifact) error {
186
184
return nil
187
185
}
188
186
189
- func (lp * pusher ) writeManifest (ctx context.Context , t partial.WithRawManifest ) error {
187
+ func (lp * sink ) writeManifest (ctx context.Context , t partial.WithRawManifest ) error {
190
188
m , err := taggableToManifest (t )
191
189
if err != nil {
192
190
return err
@@ -220,7 +218,7 @@ func (lp *pusher) writeManifest(ctx context.Context, t partial.WithRawManifest)
220
218
return nil
221
219
}
222
220
223
- func (lp * pusher ) writeChild (ctx context.Context , child partial.Describable , g * errgroup.Group ) error {
221
+ func (lp * sink ) writeChild (ctx context.Context , child partial.Describable , g * errgroup.Group ) error {
224
222
switch child := child .(type ) {
225
223
case v1.ImageIndex :
226
224
// For recursive index, we want to do a depth-first launching of goroutines
@@ -244,7 +242,7 @@ func (lp *pusher) writeChild(ctx context.Context, child partial.Describable, g *
244
242
}
245
243
246
244
// Push implements remote.Pusher.
247
- func (lp * pusher ) Push (ctx context.Context , ref name.Reference , t partial.WithRawManifest ) error {
245
+ func (lp * sink ) Push (ctx context.Context , ref name.Reference , t partial.WithRawManifest ) error {
248
246
err := lp .writeManifest (ctx , t )
249
247
if err != nil {
250
248
return err
@@ -264,7 +262,7 @@ func (lp *pusher) Push(ctx context.Context, ref name.Reference, t partial.WithRa
264
262
}
265
263
266
264
// Upload implements remote.Pusher.
267
- func (lp * pusher ) Upload (_ context.Context , _ name.Repository , l v1.Layer ) error {
265
+ func (lp * sink ) Upload (_ context.Context , _ name.Repository , l v1.Layer ) error {
268
266
digest , err := l .Digest ()
269
267
if err != nil {
270
268
return err
@@ -276,10 +274,10 @@ func (lp *pusher) Upload(_ context.Context, _ name.Repository, l v1.Layer) error
276
274
return lp .path .WriteBlob (digest , rc )
277
275
}
278
276
279
- func NewPusher (path Path ) remote. Pusher {
280
- return & pusher {
277
+ func NewSink (path Path ) sourcesink. Sink {
278
+ return & sink {
281
279
path ,
282
280
}
283
281
}
284
282
285
- var _ remote. Pusher = (* pusher )(nil )
283
+ var _ sourcesink. Sink = (* sink )(nil )
0 commit comments