mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-05-18 09:17:49 +08:00
build: enhance error message for unsupported attestations
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
parent
56fc68eb7e
commit
5a466918f9
@ -252,17 +252,21 @@ func toSolveOpt(ctx context.Context, node builder.Node, multiDriver bool, opt Op
|
|||||||
attests[k] = *v
|
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 len(attests) > 0 {
|
||||||
if !supportsAttestations {
|
if !supportAttestations {
|
||||||
return nil, nil, errors.Errorf("attestations are not supported by the current BuildKit daemon")
|
if !nodeDriver.Features(ctx)[driver.MultiPlatform] {
|
||||||
|
return nil, nil, notSupported("Attestation", nodeDriver, "https://docs.docker.com/go/attestations/")
|
||||||
|
}
|
||||||
|
return nil, nil, errors.Errorf("Attestations are not supported by the current BuildKit daemon")
|
||||||
}
|
}
|
||||||
for k, v := range attests {
|
for k, v := range attests {
|
||||||
so.FrontendAttrs["attest:"+k] = v
|
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"
|
const noAttestEnv = "BUILDX_NO_DEFAULT_ATTESTATIONS"
|
||||||
var noProv bool
|
var noProv bool
|
||||||
if v, ok := os.LookupEnv(noAttestEnv); ok {
|
if v, ok := os.LookupEnv(noAttestEnv); ok {
|
||||||
|
@ -118,7 +118,7 @@ func testBuildRegistryExportAttestations(t *testing.T, sb integration.Sandbox) {
|
|||||||
out, err := buildCmd(sb, withArgs(fmt.Sprintf("--output=type=image,name=%s,push=true", target), "--provenance=true", dir))
|
out, err := buildCmd(sb, withArgs(fmt.Sprintf("--output=type=image,name=%s,push=true", target), "--provenance=true", dir))
|
||||||
if sb.Name() == "docker" {
|
if sb.Name() == "docker" {
|
||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
require.Contains(t, out, "attestations are not supported")
|
require.Contains(t, out, "Attestation is not supported")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
require.NoError(t, err, string(out))
|
require.NoError(t, err, string(out))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user