MCPcopy Create free account
hub / github.com/containerd/imgcrypt / ingestReader

Function ingestReader

images/encryption/encryption.go:250–273  ·  view source on GitHub ↗
(ctx context.Context, cs content.Ingester, ref string, r io.Reader)

Source from the content-addressed store, hash-verified

248}
249
250func ingestReader(ctx context.Context, cs content.Ingester, ref string, r io.Reader) (digest.Digest, int64, error) {
251 cw, err := content.OpenWriter(ctx, cs, content.WithRef(ref))
252 if err != nil {
253 return "", 0, fmt.Errorf("failed to open writer: %w", err)
254 }
255 defer cw.Close()
256
257 if _, err := content.CopyReader(cw, r); err != nil {
258 return "", 0, fmt.Errorf("copy failed: %w", err)
259 }
260
261 st, err := cw.Status()
262 if err != nil {
263 return "", 0, fmt.Errorf("failed to get state: %w", err)
264 }
265
266 if err := cw.Commit(ctx, st.Offset, ""); err != nil {
267 if !errdefs.IsAlreadyExists(err) {
268 return "", 0, fmt.Errorf("failed commit on ref %q: %w", ref, err)
269 }
270 }
271
272 return cw.Digest(), st.Offset, nil
273}
274
275// Encrypt or decrypt all the Children of a given descriptor
276func cryptChildren(ctx context.Context, cs content.Store, desc ocispec.Descriptor, cc *encconfig.CryptoConfig, lf LayerFilter, cryptoOp cryptoOp, _ *ocispec.Platform) (ocispec.Descriptor, bool, error) {

Callers 1

cryptLayerFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…