-
Notifications
You must be signed in to change notification settings - Fork 1k
Expand file tree
/
Copy pathcache_push.go
More file actions
44 lines (40 loc) · 1.8 KB
/
cache_push.go
File metadata and controls
44 lines (40 loc) · 1.8 KB
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
35
36
37
38
39
40
41
42
43
44
package main
import (
cachepkg "github.com/linuxkit/linuxkit/src/cmd/linuxkit/cache"
"github.com/linuxkit/linuxkit/src/cmd/linuxkit/util"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)
func cachePushCmd() *cobra.Command {
var (
remoteName string
pushArchSpecificTags bool
override bool
)
cmd := &cobra.Command{
Use: "push",
Short: "push images from the linuxkit cache",
Long: `Push named images from the linuxkit cache to registry. Can provide short name, like linuxkit/kernel:6.6.13
or nginx, or canonical name, like docker.io/library/nginx:latest.
It is efficient, as blobs with the same content are not replaced.`,
Args: cobra.MinimumNArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
names := args
for _, name := range names {
fullname := util.ReferenceExpand(name)
p, err := cachepkg.NewProvider(cacheDir)
if err != nil {
log.Fatalf("unable to read a local cache: %v", err)
}
if err := p.Push(fullname, remoteName, pushArchSpecificTags, override); err != nil {
log.Fatalf("unable to push image named %s: %v", name, err)
}
}
return nil
},
}
cmd.Flags().StringVar(&remoteName, "remote-name", "", "Push it under a different name, e.g. push local image foo/bar:mine as baz/bee:yours. If blank, uses same local name.")
cmd.Flags().BoolVar(&pushArchSpecificTags, "with-arch-tags", false, "When the local reference is an index, add to the remote arch-specific tags for each arch in the index, each as their own tag with the same name as the index, but with the architecture appended, e.g. image:foo will have image:foo-amd64, image:foo-arm64, etc.")
cmd.Flags().BoolVar(&override, "override", false, "Even if the image already exists in the registry, push it again, overwriting the existing image.")
return cmd
}