MCPcopy
hub / github.com/containerd/containerd / ReadBlob

Function ReadBlob

core/content/helpers.go:98–124  ·  view source on GitHub ↗

ReadBlob retrieves the entire contents of the blob from the provider. Avoid using this for large blobs, such as layers.

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

Source from the content-addressed store, hash-verified

96//
97// Avoid using this for large blobs, such as layers.
98func ReadBlob(ctx context.Context, provider Provider, desc ocispec.Descriptor) ([]byte, error) {
99 useData, err := useDescriptorData(desc)
100 if err != nil {
101 return nil, err
102 }
103 if useData {
104 return desc.Data, nil
105 }
106
107 ra, err := provider.ReaderAt(ctx, desc)
108 if err != nil {
109 return nil, err
110 }
111 defer ra.Close()
112
113 p := make([]byte, ra.Size())
114
115 n, err := ra.ReadAt(p, 0)
116 if err == io.EOF {
117 if int64(n) != ra.Size() {
118 err = io.ErrUnexpectedEOF
119 } else {
120 err = nil
121 }
122 }
123 return p, err
124}
125
126// WriteBlob writes data with the expected digest into the content store. If
127// expected already exists, the method returns immediately and the reader will

Callers 15

GetOCIStopSignalFunction · 0.92
SpecMethod · 0.92
WithRestoreRuntimeFunction · 0.92
WithRestoreSpecFunction · 0.92
WithImageConfigLabelsFunction · 0.92
decodeIndexFunction · 0.92
withImageFunction · 0.92
unpackMethod · 0.92
ConvertManifestFunction · 0.92
importStreamMethod · 0.92
checkContentFunction · 0.92
ManifestFunction · 0.92

Calls 5

useDescriptorDataFunction · 0.85
ReaderAtMethod · 0.65
CloseMethod · 0.65
SizeMethod · 0.65
ReadAtMethod · 0.45

Tested by 2

withImageFunction · 0.74

Used in the wild real call sites across dependent graphs

searching dependent graphs…