Skip to content

Commit 642f28f

Browse files
committed
imagetools: process com.docker.reference.* annotations
To give us the option later down the road of producing recommended OCI names in BuildKit (using com instead of vnd, woops), we need to update Buildx to be able to process both. Ideally, if a Buildx/BuildKit release hadn't been made we could just switch over, but since we have, we'd need to support both (at least for a while, eventually we could consider deprecating+removing the vnd variant). Signed-off-by: Justin Chadwell <[email protected]>
1 parent 78058ce commit 642f28f

1 file changed

Lines changed: 16 additions & 5 deletions

File tree

util/imagetools/loader.go

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,11 @@ import (
2121
"golang.org/x/sync/errgroup"
2222
)
2323

24-
const (
25-
annotationReference = "vnd.docker.reference.digest"
24+
var (
25+
annotationReferences = []string{
26+
"com.docker.reference.digest",
27+
"vnd.docker.reference.digest", // TODO: deprecate/remove after migration to new annotation
28+
}
2629
)
2730

2831
type contentCache interface {
@@ -167,16 +170,24 @@ func (l *loader) fetch(ctx context.Context, fetcher remotes.Fetcher, desc ocispe
167170
}
168171
r.mu.Unlock()
169172

170-
ref, ok := desc.Annotations[annotationReference]
171-
if ok {
173+
found := false
174+
for _, annotationReference := range annotationReferences {
175+
ref, ok := desc.Annotations[annotationReference]
176+
if !ok {
177+
continue
178+
}
179+
172180
refdgst, err := digest.Parse(ref)
173181
if err != nil {
174182
return err
175183
}
176184
r.mu.Lock()
177185
r.refs[refdgst] = append(r.refs[refdgst], desc.Digest)
178186
r.mu.Unlock()
179-
} else {
187+
found = true
188+
break
189+
}
190+
if !found {
180191
p := desc.Platform
181192
if p == nil {
182193
p, err = l.readPlatformFromConfig(ctx, fetcher, mfst.Config)

0 commit comments

Comments
 (0)