MCPcopy
hub / github.com/containerd/containerd / Children

Function Children

core/images/image.go:337–377  ·  view source on GitHub ↗

Children returns the immediate children of content described by the descriptor.

(ctx context.Context, provider content.Provider, desc ocispec.Descriptor)

Source from the content-addressed store, hash-verified

335
336// Children returns the immediate children of content described by the descriptor.
337func Children(ctx context.Context, provider content.Provider, desc ocispec.Descriptor) ([]ocispec.Descriptor, error) {
338 if IsManifestType(desc.MediaType) {
339 p, err := content.ReadBlob(ctx, provider, desc)
340 if err != nil {
341 return nil, err
342 }
343
344 if err := validateMediaType(p, desc.MediaType); err != nil {
345 return nil, fmt.Errorf("children: invalid desc %s: %w", desc.Digest, err)
346 }
347
348 // TODO(stevvooe): We just assume oci manifest, for now. There may be
349 // subtle differences from the docker version.
350 var manifest ocispec.Manifest
351 if err := json.Unmarshal(p, &manifest); err != nil {
352 return nil, err
353 }
354
355 return append([]ocispec.Descriptor{manifest.Config}, manifest.Layers...), nil
356 } else if IsIndexType(desc.MediaType) {
357 p, err := content.ReadBlob(ctx, provider, desc)
358 if err != nil {
359 return nil, err
360 }
361
362 if err := validateMediaType(p, desc.MediaType); err != nil {
363 return nil, fmt.Errorf("children: invalid desc %s: %w", desc.Digest, err)
364 }
365
366 var index ocispec.Index
367 if err := json.Unmarshal(p, &index); err != nil {
368 return nil, err
369 }
370
371 return append([]ocispec.Descriptor{}, index.Manifests...), nil
372 } else if !IsLayerType(desc.MediaType) && !IsKnownConfig(desc.MediaType) && !IsAttestationType(desc.MediaType) {
373 // Layers, configs, and attestations are childless data types and should not be logged.
374 log.G(ctx).Debugf("encountered unknown type %v; children may not be fetched", desc.MediaType)
375 }
376 return nil, nil
377}
378
379// unknownDocument represents a manifest, manifest list, or index that has not
380// yet been validated.

Callers 9

ImportMethod · 0.92
TestImportFunction · 0.92
TestExportAllCasesFunction · 0.92
isImageInArchiveFunction · 0.92
getPlatformManifestFunction · 0.92
importStreamMethod · 0.92
WithSkipMissingFunction · 0.92
push.goFile · 0.92
ChildrenHandlerFunction · 0.85

Calls 8

ReadBlobFunction · 0.92
IsManifestTypeFunction · 0.85
validateMediaTypeFunction · 0.85
IsIndexTypeFunction · 0.85
IsLayerTypeFunction · 0.85
IsKnownConfigFunction · 0.85
IsAttestationTypeFunction · 0.85
UnmarshalMethod · 0.80

Tested by 4

TestImportFunction · 0.74
TestExportAllCasesFunction · 0.74
isImageInArchiveFunction · 0.74
getPlatformManifestFunction · 0.74

Used in the wild real call sites across dependent graphs

searching dependent graphs…