MCPcopy Index your code
hub / github.com/linuxkit/linuxkit / cacheRmCmd

Function cacheRmCmd

src/cmd/linuxkit/cache_rm.go:9–48  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

7)
8
9func cacheRmCmd() *cobra.Command {
10 var (
11 publishedOnly bool
12 )
13 cmd := &cobra.Command{
14 Use: "rm",
15 Short: "remove individual images from the linuxkit cache",
16 Long: `Remove individual images from the linuxkit cache.`,
17 Args: cobra.MinimumNArgs(1),
18 RunE: func(cmd *cobra.Command, args []string) error {
19 imageNames := args
20
21 // did we limit to published only?
22
23 // list all of the images and content in the cache
24 p, err := cachepkg.NewProvider(cacheDir)
25 if err != nil {
26 log.Fatalf("unable to read a local cache: %v", err)
27 }
28 images := map[string]string{}
29 for _, imageName := range imageNames {
30 desc, err := p.FindRoot(imageName)
31 if err != nil {
32 log.Fatalf("error reading image %s: %v", imageName, err)
33 }
34 dig, err := desc.Digest()
35 if err != nil {
36 log.Fatalf("error reading digest for image %s: %v", imageName, err)
37 }
38 images[imageName] = dig.String()
39 }
40 removeImagesFromCache(images, p, publishedOnly)
41 return nil
42 },
43 }
44
45 cmd.Flags().BoolVar(&publishedOnly, "published-only", false, "Only clean images that linuxkit can confirm at the time of running have been published to the registry")
46
47 return cmd
48}

Callers 1

cacheCmdFunction · 0.85

Calls 4

FindRootMethod · 0.95
removeImagesFromCacheFunction · 0.85
DigestMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected