Skip to content

Commit bc9cb2c

Browse files
committed
Add env var to disable default attestations
For certain cases we need to build with `--provenance=false`. However not all build envs (especially in the OSS ethos) have the latest buildx so just blanket setting `--provenance=false` will fail in these cases. Having an env var allows people to set the value without having to worry about if the buildx version has the `--provenance` flag. Signed-off-by: Brian Goff <[email protected]>
1 parent a4f01b4 commit bc9cb2c

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

‎build/build.go‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,8 +462,19 @@ func toSolveOpt(ctx context.Context, node builder.Node, multiDriver bool, opt Op
462462
so.FrontendAttrs[k] = v
463463
}
464464
}
465+
465466
if _, ok := opt.Attests["attest:provenance"]; !ok && supportsAttestations {
466-
so.FrontendAttrs["attest:provenance"] = "mode=min,inline-only=true"
467+
const noAttestEnv = "BUILDX_NO_DEFAULT_ATTESTATIONS"
468+
var noProv bool
469+
if v, ok := os.LookupEnv(noAttestEnv); ok {
470+
noProv, err = strconv.ParseBool(v)
471+
if err != nil {
472+
return nil, nil, errors.Wrap(err, "invalid "+noAttestEnv)
473+
}
474+
}
475+
if !noProv {
476+
so.FrontendAttrs["attest:provenance"] = "mode=min,inline-only=true"
477+
}
467478
}
468479

469480
switch len(opt.Exports) {

0 commit comments

Comments
 (0)