Skip to content

Commit 78d66df

Browse files
committed
fix: add backwards depot build compatibility of enabled=false of provenance
Signed-off-by: Chris Goller <[email protected]>
1 parent e615afb commit 78d66df

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

pkg/buildx/build/build.go

+19-1
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,25 @@ func toSolveOpt(ctx context.Context, node builder.Node, multiDriver bool, opt Op
408408
so.FrontendAttrs[k] = v
409409
}
410410
}
411-
if _, ok := opt.Attests["attest:provenance"]; !ok && supportsAttestations {
411+
412+
// DEPOT: Bake uses "provenance" and build uses "attest:provenance".
413+
//
414+
// There are three cases:
415+
//
416+
// When the CLI arg is --provenance=false, the value is nil, attests[] is not set and so.FrontAttrs[] is not set
417+
// When the CLI arg is --provenance=true, the value is not nil, attests[] and so.FrontAttrs[] are set.
418+
// When the CLI arg is not specified, attests[] is NOT set and so.FrontendAttrs[] IS set.
419+
// Thus, NOT setting --provenance will by default add provenance.
420+
//
421+
// If attests[] is set and exporting to docker tar, the command will error with:
422+
// "docker exporter does not currently support exporting manifest lists"
423+
//
424+
// This means that not setting --provenance and exporting to docker will work, but
425+
// setting --provenance=true and exporting to docker will error.
426+
_, hasBuildProvenance := opt.Attests["attest:provenance"]
427+
_, hasBakeProvenance := opt.Attests["provenance"]
428+
hasProvenance := hasBuildProvenance || hasBakeProvenance
429+
if !hasProvenance && supportsAttestations {
412430
so.FrontendAttrs["attest:provenance"] = "mode=min,inline-only=true"
413431
}
414432

0 commit comments

Comments
 (0)