Skip to content

Commit

Permalink
build: enhance error message for unsupported attestations
Browse files Browse the repository at this point in the history
Signed-off-by: CrazyMax <[email protected]>
  • Loading branch information
crazy-max committed Feb 22, 2024
1 parent 56fc68e commit d2d74db
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions build/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,17 +252,22 @@ func toSolveOpt(ctx context.Context, node builder.Node, multiDriver bool, opt Op
attests[k] = *v
}
}
supportsAttestations := bopts.LLBCaps.Contains(apicaps.CapID("exporter.image.attestations")) && nodeDriver.Features(ctx)[driver.MultiPlatform]

supportAttestations := bopts.LLBCaps.Contains(apicaps.CapID("exporter.image.attestations")) && nodeDriver.Features(ctx)[driver.MultiPlatform]
if len(attests) > 0 {
if !supportsAttestations {
return nil, nil, errors.Errorf("attestations are not supported by the current BuildKit daemon")
if !supportAttestations {
if !nodeDriver.Features(ctx)[driver.MultiPlatform] {
return nil, nil, errors.Errorf(`Attestations are not supported for the %s driver.
Switch to a different driver, or turn on the containerd image store, and try again.`, nodeDriver.Factory().Name())
}
return nil, nil, errors.Errorf("Attestations are not supported by the current BuildKit daemon")
}
for k, v := range attests {
so.FrontendAttrs["attest:"+k] = v
}
}

if _, ok := opt.Attests["provenance"]; !ok && supportsAttestations {
if _, ok := opt.Attests["provenance"]; !ok && supportAttestations {
const noAttestEnv = "BUILDX_NO_DEFAULT_ATTESTATIONS"
var noProv bool
if v, ok := os.LookupEnv(noAttestEnv); ok {
Expand Down

0 comments on commit d2d74db

Please sign in to comment.