MCPcopy Create free account
hub / github.com/containerd/nerdctl / getDigestFromMetaFile

Function getDigestFromMetaFile

pkg/cmd/builder/build.go:493–515  ·  view source on GitHub ↗
(path string)

Source from the content-addressed store, hash-verified

491}
492
493func getDigestFromMetaFile(path string) (string, error) {
494 data, err := filesystem.ReadFile(path)
495 if err != nil {
496 return "", err
497 }
498 defer os.Remove(path)
499
500 metadata := map[string]json.RawMessage{}
501 if err := json.Unmarshal(data, &metadata); err != nil {
502 log.L.WithError(err).Errorf("failed to unmarshal metadata file %s", path)
503 return "", err
504 }
505 digestRaw, ok := metadata["containerimage.digest"]
506 if !ok {
507 return "", errors.New("failed to find containerimage.digest in metadata file")
508 }
509 var digest string
510 if err := json.Unmarshal(digestRaw, &digest); err != nil {
511 log.L.WithError(err).Errorf("failed to unmarshal digset")
512 return "", err
513 }
514 return digest, nil
515}
516
517func isMatchingRuntimePlatform(platform string, parser PlatformParser) bool {
518 p, err := parser.Parse(platform)

Callers 1

BuildFunction · 0.85

Calls 3

ReadFileFunction · 0.92
UnmarshalMethod · 0.80
RemoveMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…