Skip to content

Commit

Permalink
imagetools: process com.docker.reference.* annotations
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
jedevc committed Feb 14, 2023
1 parent 78058ce commit 642f28f
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions util/imagetools/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@ import (
"golang.org/x/sync/errgroup"
)

const (
annotationReference = "vnd.docker.reference.digest"
var (
annotationReferences = []string{
"com.docker.reference.digest",
"vnd.docker.reference.digest", // TODO: deprecate/remove after migration to new annotation
}
)

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

ref, ok := desc.Annotations[annotationReference]
if ok {
found := false
for _, annotationReference := range annotationReferences {
ref, ok := desc.Annotations[annotationReference]
if !ok {
continue
}

refdgst, err := digest.Parse(ref)
if err != nil {
return err
}
r.mu.Lock()
r.refs[refdgst] = append(r.refs[refdgst], desc.Digest)
r.mu.Unlock()
} else {
found = true
break
}
if !found {
p := desc.Platform
if p == nil {
p, err = l.readPlatformFromConfig(ctx, fetcher, mfst.Config)
Expand Down

0 comments on commit 642f28f

Please sign in to comment.