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)
| 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. |
| 51 | func 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 |
nothing calls this directly
no test coverage detected
searching dependent graphs…