Skip to content
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions exporter/containerimage/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"context"
"encoding/json"
"fmt"
"strconv"
"strings"
"time"

Expand Down Expand Up @@ -111,10 +112,15 @@ func (ic *ImageWriter) Commit(ctx context.Context, inp *exporter.Source, session
ref = inp.Ref
} else if len(p.Platforms) > 0 {
p := p.Platforms[0]
if _, ok := inp.Attestations[p.ID]; ok {
return nil, errors.Errorf("cannot export attestations without multi-platform enabled")
}
ref = inp.Refs[p.ID]
if atts, ok := inp.Attestations[p.ID]; ok {
atts = attestation.Filter(atts, nil, map[string][]byte{
result.AttestationInlineOnlyKey: []byte(strconv.FormatBool(true)),
})
if len(atts) > 0 {
return nil, errors.Errorf("cannot export attestations without multi-platform enabled")
}
}
} else if len(inp.Refs) == 1 {
for _, ref = range inp.Refs {
}
Expand Down
12 changes: 8 additions & 4 deletions exporter/oci/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,14 @@ func (e *imageExporter) Resolve(ctx context.Context, opt map[string]string) (exp
return nil, err
}

if e.opt.Variant == VariantDocker {
if i.opts.MultiPlatform != nil && *i.opts.MultiPlatform {
return nil, errors.Errorf("docker exporter does not currently support exporting manifest lists")
}
b := false
i.opts.MultiPlatform = &b
}

for k, v := range opt {
switch k {
case keyTar:
Expand Down Expand Up @@ -115,10 +123,6 @@ func (e *imageExporterInstance) Config() *exporter.Config {
}

func (e *imageExporterInstance) Export(ctx context.Context, src *exporter.Source, sessionID string) (map[string]string, error) {
if e.opt.Variant == VariantDocker && len(src.Refs) > 0 {
return nil, errors.Errorf("docker exporter does not currently support exporting manifest lists")
}

if src.Metadata == nil {
src.Metadata = make(map[string][]byte)
}
Expand Down
4 changes: 2 additions & 2 deletions exporter/util/multiplatform/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ const (
)

func ParseBuildArgs(opt map[string]string) (string, bool) {
if v, ok := opt[frontendMultiPlatform]; ok {
if v, ok := opt[frontendMultiPlatformArg]; ok {
return v, true
}
if v, ok := opt[frontendMultiPlatformArg]; ok {
if v, ok := opt[frontendMultiPlatform]; ok {
return v, true
}
return "", false
Expand Down
17 changes: 15 additions & 2 deletions frontend/gateway/grpcclient/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
gogotypes "github.com/gogo/protobuf/types"
"github.com/golang/protobuf/ptypes/any"
"github.com/moby/buildkit/client/llb"
"github.com/moby/buildkit/frontend/attestations"
"github.com/moby/buildkit/frontend/gateway/client"
pb "github.com/moby/buildkit/frontend/gateway/pb"
"github.com/moby/buildkit/identity"
Expand Down Expand Up @@ -161,7 +162,7 @@ func (c *grpcClient) Run(ctx context.Context, f client.BuildFunc) (retError erro
}
}

if res.Attestations != nil && c.caps.Supports(pb.CapAttestations) == nil {
if res.Attestations != nil {
attestations := map[string]*pb.Attestations{}
for k, as := range res.Attestations {
for _, a := range as {
Expand Down Expand Up @@ -483,8 +484,20 @@ func (c *grpcClient) ResolveImageConfig(ctx context.Context, ref string, opt llb
}

func (c *grpcClient) BuildOpts() client.BuildOpts {
opts := c.opts
if c.caps.Supports(pb.CapAttestations) == nil {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Supports() == nil means that capability IS supported.

I think the better behavior in this cases would be to make sure AddAttestation is a noop if daemon has no support.

opts = map[string]string{}
attestOpts := attestations.Filter(c.opts)
for k, v := range c.opts {
if _, ok := attestOpts[k]; ok {
continue
}
opts[k] = v
}
}

return client.BuildOpts{
Opts: c.opts,
Opts: opts,
SessionID: c.sessionID,
Workers: c.workers,
Product: c.product,
Expand Down