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

Method Remove

src/cmd/linuxkit/cache/remove.go:14–69  ·  view source on GitHub ↗

Remove removes all references pointed to by the provided reference, whether it is an image or an index. If it is not found, it is a no-op. This should be viewed as "Ensure this reference is not in the cache", rather than "Remove this reference from the cache".

(name string)

Source from the content-addressed store, hash-verified

12// If it is not found, it is a no-op. This should be viewed as "Ensure this reference is not in the cache",
13// rather than "Remove this reference from the cache".
14func (p *Provider) Remove(name string) error {
15 root, err := p.FindRoot(name)
16 if err != nil {
17 return err
18 }
19 var blobs []v1.Hash
20 // the provided name could be an image or an index, so we need to check both
21 img, err := root.Image()
22 if err == nil {
23 imgBlobs, err := blobsForImage(img)
24 if err != nil {
25 return err
26 }
27 blobs = append(blobs, imgBlobs...)
28 imgDigest, err := img.Digest()
29 if err != nil {
30 return err
31 }
32 blobs = append(blobs, imgDigest)
33 } else {
34 ii, err := root.ImageIndex()
35 if err != nil {
36 return nil
37 }
38 // get blobs for each provided image
39 manifests, err := ii.IndexManifest()
40 if err != nil {
41 return fmt.Errorf("unable to list manifests in index for %s: %v", name, err)
42 }
43 for _, man := range manifests.Manifests {
44 img, err := ii.Image(man.Digest)
45 if err != nil {
46 return fmt.Errorf("unable to get image for digest %s in index for %s: %v", man.Digest, name, err)
47 }
48 imgBlobs, err := blobsForImage(img)
49 if err != nil {
50 return err
51 }
52 blobs = append(blobs, imgBlobs...)
53 blobs = append(blobs, man.Digest)
54 }
55 indexDigest, err := ii.Digest()
56 if err != nil {
57 return err
58 }
59 blobs = append(blobs, indexDigest)
60 }
61 // at this point, blobs contains all of the blobs that need to be removed.
62 for _, blob := range blobs {
63 log.Debugf("removing blob %s", blob)
64 if err := p.cache.RemoveBlob(blob); err != nil {
65 log.Warnf("unable to remove blob %s for %s: %v", blob, name, err)
66 }
67 }
68 return p.RemoveDescriptors(match.Name(name))
69}
70
71func blobsForImage(img v1.Image) ([]v1.Hash, error) {

Callers 11

copyFSFunction · 0.80
PathMethod · 0.80
runcInitFunction · 0.80
systemInitCmdFunction · 0.80
mainFunction · 0.80
ringBufferHandlerFunction · 0.80
mainFunction · 0.80
removeImagesFromCacheFunction · 0.80
createListenSocketFunction · 0.80
buildCmdFunction · 0.80
runVBoxCmdFunction · 0.80

Implementers 11

ProviderCDROMpkg/metadata/provider_cdrom.go
ProviderGCPpkg/metadata/provider_gcp.go
ProviderVMwarepkg/metadata/provider_vmware_unsupport
ProviderEquinixMetalpkg/metadata/provider_equinixmetal.go
ProviderVultrpkg/metadata/provider_vultr.go
ProviderDigitalOceanpkg/metadata/provider_digitalocean.go
ProviderHetznerpkg/metadata/provider_hetzner.go
ProviderMetaldatapkg/metadata/provider_metaldata.go
ProviderOpenstackpkg/metadata/provider_openstack.go
ProviderScalewaypkg/metadata/provider_scaleway.go
ProviderAWSpkg/metadata/provider_aws.go

Calls 6

FindRootMethod · 0.95
RemoveDescriptorsMethod · 0.95
blobsForImageFunction · 0.85
ImageMethod · 0.65
DigestMethod · 0.65
ImageIndexMethod · 0.65

Tested by

no test coverage detected