MCPcopy Index your code
hub / github.com/containerd/containerd / MakeRefKey

Function MakeRefKey

core/remotes/handlers.go:79–113  ·  view source on GitHub ↗

MakeRefKey returns a stable ingest reference for desc. The returned key is used as a content-store reference to correlate ongoing fetch and push operations for the same descriptor. The key is derived from the descriptor digest and, when present, the [ocispec.AnnotationRefName] annotation. By defau

(ctx context.Context, desc ocispec.Descriptor)

Source from the content-addressed store, hash-verified

77// If the media type is not recognized and no context override exists,
78// MakeRefKey falls back to the "unknown-" prefix.
79func MakeRefKey(ctx context.Context, desc ocispec.Descriptor) string {
80 key := desc.Digest.String()
81 if desc.Annotations != nil {
82 if name, ok := desc.Annotations[ocispec.AnnotationRefName]; ok {
83 key = fmt.Sprintf("%s@%s", name, desc.Digest.String())
84 }
85 }
86
87 if v := ctx.Value(refKeyPrefix{}); v != nil {
88 values := v.(map[string]string)
89 if prefix := values[desc.MediaType]; prefix != "" {
90 return prefix + "-" + key
91 }
92 }
93
94 switch {
95 case images.IsManifestType(desc.MediaType):
96 return "manifest-" + key
97 case images.IsIndexType(desc.MediaType):
98 return "index-" + key
99 case images.IsLayerType(desc.MediaType):
100 return "layer-" + key
101 case images.IsKnownConfig(desc.MediaType):
102 return "config-" + key
103 case images.IsAttestationType(desc.MediaType):
104 return "attestation-" + key
105 default:
106 log.G(ctx).WithFields(log.Fields{
107 "digest": desc.Digest,
108 "mediatype": desc.MediaType,
109 "artifactType": desc.ArtifactType,
110 }).Debug("using generic reference key prefix for unclassified descriptor")
111 return "unknown-" + key
112 }
113}
114
115// FetchHandler returns a handler that will fetch all content into the ingester
116// discovered in a call to Dispatch. Use with ChildrenHandler to do a full

Callers 11

TestPusherErrResetFunction · 0.92
PushMethod · 0.92
ConvertManifestFunction · 0.92
PushMethod · 0.92
HandleProgressMethod · 0.92
ShowProgressFunction · 0.92
push.goFile · 0.92
FetchFunction · 0.85
pushFunction · 0.85

Calls 6

IsManifestTypeFunction · 0.92
IsIndexTypeFunction · 0.92
IsLayerTypeFunction · 0.92
IsKnownConfigFunction · 0.92
IsAttestationTypeFunction · 0.92
StringMethod · 0.45

Tested by 3

TestPusherErrResetFunction · 0.74

Used in the wild real call sites across dependent graphs

searching dependent graphs…