Skip to content

Commit c3d1dcc

Browse files
authored
Create remote.Push (#1978)
This exposes a function with the same signature as `remote.{Tag,Put}` using `Taggable` but that has the semantics of `remote.Write[Index` wrt writing the consituent elements of the taggable. Signed-off-by: Matt Moore <[email protected]>
1 parent d36047a commit c3d1dcc

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

Diff for: pkg/v1/remote/write.go

+14-16
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,7 @@ type Taggable interface {
4545

4646
// Write pushes the provided img to the specified image reference.
4747
func Write(ref name.Reference, img v1.Image, options ...Option) (rerr error) {
48-
o, err := makeOptions(options...)
49-
if err != nil {
50-
return err
51-
}
52-
if o.progress != nil {
53-
defer func() { o.progress.Close(rerr) }()
54-
}
55-
return newPusher(o).Push(o.context, ref, img)
48+
return Push(ref, img, options...)
5649
}
5750

5851
// writer writes the elements of an image to a remote image reference.
@@ -656,14 +649,7 @@ func scopesForUploadingImage(repo name.Repository, layers []v1.Layer) []string {
656649
// WriteIndex will attempt to push all of the referenced manifests before
657650
// attempting to push the ImageIndex, to retain referential integrity.
658651
func WriteIndex(ref name.Reference, ii v1.ImageIndex, options ...Option) (rerr error) {
659-
o, err := makeOptions(options...)
660-
if err != nil {
661-
return err
662-
}
663-
if o.progress != nil {
664-
defer func() { o.progress.Close(rerr) }()
665-
}
666-
return newPusher(o).Push(o.context, ref, ii)
652+
return Push(ref, ii, options...)
667653
}
668654

669655
// WriteLayer uploads the provided Layer to the specified repo.
@@ -711,3 +697,15 @@ func Put(ref name.Reference, t Taggable, options ...Option) error {
711697
}
712698
return newPusher(o).Put(o.context, ref, t)
713699
}
700+
701+
// Push uploads the given Taggable to the specified reference.
702+
func Push(ref name.Reference, t Taggable, options ...Option) (rerr error) {
703+
o, err := makeOptions(options...)
704+
if err != nil {
705+
return err
706+
}
707+
if o.progress != nil {
708+
defer func() { o.progress.Close(rerr) }()
709+
}
710+
return newPusher(o).Push(o.context, ref, t)
711+
}

0 commit comments

Comments
 (0)