Skip to content

Commit 7ae0a60

Browse files
committed
Add OCI ref.name to unique key in remotes handler
This allows a pusher to be used for more than one tag without creating a new resolver/pusher. The current implementation checks the ref key tracker status based on type and hash and will skip the push even if the repository reference is unique. Signed-off-by: Phil Estes <[email protected]>
1 parent 9a9bd09 commit 7ae0a60

1 file changed

Lines changed: 13 additions & 6 deletions

File tree

remotes/handlers.go

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,25 +56,32 @@ func WithMediaTypeKeyPrefix(ctx context.Context, mediaType, prefix string) conte
5656
// used to lookup ongoing processes related to the descriptor. This function
5757
// may look to the context to namespace the reference appropriately.
5858
func MakeRefKey(ctx context.Context, desc ocispec.Descriptor) string {
59+
key := desc.Digest.String()
60+
if desc.Annotations != nil {
61+
if name, ok := desc.Annotations[ocispec.AnnotationRefName]; ok {
62+
key = fmt.Sprintf("%s@%s", name, desc.Digest.String())
63+
}
64+
}
65+
5966
if v := ctx.Value(refKeyPrefix{}); v != nil {
6067
values := v.(map[string]string)
6168
if prefix := values[desc.MediaType]; prefix != "" {
62-
return prefix + "-" + desc.Digest.String()
69+
return prefix + "-" + key
6370
}
6471
}
6572

6673
switch mt := desc.MediaType; {
6774
case mt == images.MediaTypeDockerSchema2Manifest || mt == ocispec.MediaTypeImageManifest:
68-
return "manifest-" + desc.Digest.String()
75+
return "manifest-" + key
6976
case mt == images.MediaTypeDockerSchema2ManifestList || mt == ocispec.MediaTypeImageIndex:
70-
return "index-" + desc.Digest.String()
77+
return "index-" + key
7178
case images.IsLayerType(mt):
72-
return "layer-" + desc.Digest.String()
79+
return "layer-" + key
7380
case images.IsKnownConfig(mt):
74-
return "config-" + desc.Digest.String()
81+
return "config-" + key
7582
default:
7683
log.G(ctx).Warnf("reference for unknown type: %s", mt)
77-
return "unknown-" + desc.Digest.String()
84+
return "unknown-" + key
7885
}
7986
}
8087

0 commit comments

Comments
 (0)