mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-05-23 04:07:45 +08:00
Merge pull request #1617 from jedevc/process-multiple-attestation-annotations
imagetools: process `com.docker.reference.*` annotations
This commit is contained in:
commit
74f64f88a7
@ -21,8 +21,11 @@ import (
|
|||||||
"golang.org/x/sync/errgroup"
|
"golang.org/x/sync/errgroup"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
var (
|
||||||
annotationReference = "vnd.docker.reference.digest"
|
annotationReferences = []string{
|
||||||
|
"com.docker.reference.digest",
|
||||||
|
"vnd.docker.reference.digest", // TODO: deprecate/remove after migration to new annotation
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
type contentCache interface {
|
type contentCache interface {
|
||||||
@ -167,8 +170,13 @@ func (l *loader) fetch(ctx context.Context, fetcher remotes.Fetcher, desc ocispe
|
|||||||
}
|
}
|
||||||
r.mu.Unlock()
|
r.mu.Unlock()
|
||||||
|
|
||||||
ref, ok := desc.Annotations[annotationReference]
|
found := false
|
||||||
if ok {
|
for _, annotationReference := range annotationReferences {
|
||||||
|
ref, ok := desc.Annotations[annotationReference]
|
||||||
|
if !ok {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
refdgst, err := digest.Parse(ref)
|
refdgst, err := digest.Parse(ref)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -176,7 +184,10 @@ func (l *loader) fetch(ctx context.Context, fetcher remotes.Fetcher, desc ocispe
|
|||||||
r.mu.Lock()
|
r.mu.Lock()
|
||||||
r.refs[refdgst] = append(r.refs[refdgst], desc.Digest)
|
r.refs[refdgst] = append(r.refs[refdgst], desc.Digest)
|
||||||
r.mu.Unlock()
|
r.mu.Unlock()
|
||||||
} else {
|
found = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
if !found {
|
||||||
p := desc.Platform
|
p := desc.Platform
|
||||||
if p == nil {
|
if p == nil {
|
||||||
p, err = l.readPlatformFromConfig(ctx, fetcher, mfst.Config)
|
p, err = l.readPlatformFromConfig(ctx, fetcher, mfst.Config)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user