| 8 | ) |
| 9 | |
| 10 | func cachePullCmd() *cobra.Command { |
| 11 | cmd := &cobra.Command{ |
| 12 | Use: "pull", |
| 13 | Short: "pull images to the linuxkit cache from registry", |
| 14 | Long: `Pull named images from their registry to the linuxkit cache. Can provide short name, like linuxkit/kernel:6.6.13 |
| 15 | or nginx, or canonical name, like docker.io/library/nginx:latest. Will be saved into cache as canonical. |
| 16 | Will replace in cache if found. Blobs with the same content are not replaced.`, |
| 17 | Args: cobra.MinimumNArgs(1), |
| 18 | RunE: func(cmd *cobra.Command, args []string) error { |
| 19 | names := args |
| 20 | for _, name := range names { |
| 21 | fullname := util.ReferenceExpand(name, util.ReferenceWithTag()) |
| 22 | |
| 23 | p, err := cachepkg.NewProvider(cacheDir) |
| 24 | if err != nil { |
| 25 | log.Fatalf("unable to read a local cache: %v", err) |
| 26 | } |
| 27 | |
| 28 | if err := p.Pull(fullname, true); err != nil { |
| 29 | log.Fatalf("unable to push image named %s: %v", name, err) |
| 30 | } |
| 31 | } |
| 32 | return nil |
| 33 | }, |
| 34 | } |
| 35 | |
| 36 | return cmd |
| 37 | } |