Skip to content

Commit 23eb3c3

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]> (cherry picked from commit bc9cb2c) Signed-off-by: Brian Goff <[email protected]>
1 parent 79e156b commit 23eb3c3

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

build/build.go

+12-1
Original file line numberDiff line numberDiff line change
@@ -465,8 +465,19 @@ func toSolveOpt(ctx context.Context, node builder.Node, multiDriver bool, opt Op
465465
so.FrontendAttrs[k] = v
466466
}
467467
}
468+
468469
if _, ok := opt.Attests["attest:provenance"]; !ok && supportsAttestations {
469-
so.FrontendAttrs["attest:provenance"] = "mode=min,inline-only=true"
470+
const noAttestEnv = "BUILDX_NO_DEFAULT_ATTESTATIONS"
471+
var noProv bool
472+
if v, ok := os.LookupEnv(noAttestEnv); ok {
473+
noProv, err = strconv.ParseBool(v)
474+
if err != nil {
475+
return nil, nil, errors.Wrap(err, "invalid "+noAttestEnv)
476+
}
477+
}
478+
if !noProv {
479+
so.FrontendAttrs["attest:provenance"] = "mode=min,inline-only=true"
480+
}
470481
}
471482

472483
switch len(opt.Exports) {

0 commit comments

Comments
 (0)