MCPcopy Index your code
hub / github.com/containerd/containerd / AppendInfoHandlerWrapper

Function AppendInfoHandlerWrapper

pkg/snapshotters/annotations.go:51–75  ·  view source on GitHub ↗

AppendInfoHandlerWrapper makes a handler which appends some basic information of images like digests for manifest and their child layers as annotations during unpack. These annotations will be passed to snapshotters as labels. These labels will be used mainly by remote snapshotters for querying imag

(ref string)

Source from the content-addressed store, hash-verified

49// These annotations will be passed to snapshotters as labels. These labels will be
50// used mainly by remote snapshotters for querying image contents from the remote location.
51func AppendInfoHandlerWrapper(ref string) func(f images.Handler) images.Handler {
52 return func(f images.Handler) images.Handler {
53 return images.HandlerFunc(func(ctx context.Context, desc ocispec.Descriptor) ([]ocispec.Descriptor, error) {
54 children, err := f.Handle(ctx, desc)
55 if err != nil {
56 return nil, err
57 }
58 if images.IsManifestType(desc.MediaType) {
59 for i := range children {
60 c := &children[i]
61 if images.IsLayerType(c.MediaType) {
62 if c.Annotations == nil {
63 c.Annotations = make(map[string]string)
64 }
65 c.Annotations[TargetRefLabel] = ref
66 c.Annotations[TargetLayerDigestLabel] = c.Digest.String()
67 c.Annotations[TargetImageLayersLabel] = getLayers(ctx, TargetImageLayersLabel, children[i:], labels.Validate)
68 c.Annotations[TargetManifestDigestLabel] = desc.Digest.String()
69 }
70 }
71 }
72 return children, nil
73 })
74 }
75}
76
77// getLayers returns comma-separated digests based on the passed list of
78// descriptors. The returned list contains as many digests as possible as well

Callers

nothing calls this directly

Calls 6

HandlerFuncFuncType · 0.92
IsManifestTypeFunction · 0.92
IsLayerTypeFunction · 0.92
getLayersFunction · 0.85
HandleMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…