Pass in index annotations from builds on multiple nodes

Fixes #2540

Signed-off-by: Eli Treuherz <et@arenko.group>
This commit is contained in:
Eli Treuherz
2024-06-21 11:56:54 +01:00
parent 9b100c2552
commit 3971361ed2
4 changed files with 27 additions and 10 deletions

View File

@ -14,7 +14,6 @@ import (
"github.com/containerd/containerd/remotes"
"github.com/containerd/errdefs"
"github.com/distribution/reference"
"github.com/docker/buildx/util/buildflags"
"github.com/moby/buildkit/exporter/containerimage/exptypes"
"github.com/moby/buildkit/util/contentutil"
"github.com/opencontainers/go-digest"
@ -29,7 +28,7 @@ type Source struct {
Ref reference.Named
}
func (r *Resolver) Combine(ctx context.Context, srcs []*Source, ann []string, preferIndex bool) ([]byte, ocispec.Descriptor, error) {
func (r *Resolver) Combine(ctx context.Context, srcs []*Source, ann map[exptypes.AnnotationKey]string, preferIndex bool) ([]byte, ocispec.Descriptor, error) {
eg, ctx := errgroup.WithContext(ctx)
dts := make([][]byte, len(srcs))
@ -152,11 +151,7 @@ func (r *Resolver) Combine(ctx context.Context, srcs []*Source, ann []string, pr
// annotations are only allowed on OCI indexes
indexAnnotation := make(map[string]string)
if mt == ocispec.MediaTypeImageIndex {
annotations, err := buildflags.ParseAnnotations(ann)
if err != nil {
return nil, ocispec.Descriptor{}, err
}
for k, v := range annotations {
for k, v := range ann {
switch k.Type {
case exptypes.AnnotationIndex:
indexAnnotation[k.Key] = v