-
Notifications
You must be signed in to change notification settings - Fork 229
/
push.go
34 lines (28 loc) · 923 Bytes
/
push.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package client
import (
"context"
"fmt"
"github.com/docker/distribution/reference"
"github.com/moby/buildkit/util/push"
)
// Push sends an image to a remote registry.
func (c *Client) Push(ctx context.Context, image string, insecure bool) error {
// Parse the image name and tag.
named, err := reference.ParseNormalizedNamed(image)
if err != nil {
return fmt.Errorf("parsing image name %q failed: %v", image, err)
}
// Add the latest lag if they did not provide one.
named = reference.TagNameOnly(named)
image = named.String()
// Create the worker opts.
opt, err := c.createWorkerOpt(false)
if err != nil {
return fmt.Errorf("creating worker opt failed: %v", err)
}
imgObj, err := opt.ImageStore.Get(ctx, image)
if err != nil {
return fmt.Errorf("getting image %q failed: %v", image, err)
}
return push.Push(ctx, opt.SessionManager, opt.ContentStore, imgObj.Target.Digest, image, insecure)
}