Skip to content

Commit 8c1110e

Browse files
Provenance flag fixes:
- Skip passing provenance flag to buildctl when '--provenance=disabled' - Skip listing attestation manifest on `image ls` Signed-off-by: Swapnanil-Gupta <[email protected]>
1 parent 464a473 commit 8c1110e

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

pkg/cmd/builder/build.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,15 @@ func generateBuildctlArgs(ctx context.Context, client *containerd.Client, option
404404
for _, s := range strutil.DedupeStrSlice(options.Attest) {
405405
optAttestType, optAttestAttrs, _ := strings.Cut(s, ",")
406406
if strings.HasPrefix(optAttestType, "type=") {
407+
if strings.HasPrefix(optAttestAttrs, "disabled=") {
408+
disabled, err := strconv.ParseBool(strings.TrimPrefix(optAttestAttrs, "disabled="))
409+
if err != nil {
410+
return "", nil, false, "", nil, nil, fmt.Errorf("invalid value for attribute \"disabled\"")
411+
}
412+
if disabled {
413+
continue
414+
}
415+
}
407416
optAttestType := strings.TrimPrefix(optAttestType, "type=")
408417
buildctlArgs = append(buildctlArgs, fmt.Sprintf("--opt=attest:%s=%s", optAttestType, optAttestAttrs))
409418
} else {

pkg/cmd/image/list.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,10 @@ func readIndex(ctx context.Context, provider content.Provider, snapshotter snaps
312312

313313
// Iterate over manifest descriptors and read them all
314314
for _, manifestDescriptor := range index.Manifests {
315+
if isAttestationManifestDescriptor(manifestDescriptor) {
316+
continue
317+
}
318+
315319
manifest, err := readManifest(ctx, provider, snapshotter, manifestDescriptor)
316320
if err != nil {
317321
continue
@@ -419,3 +423,9 @@ func (x *imagePrinter) printImageSinglePlatform(desc ocispec.Descriptor, img ima
419423
}
420424
return nil
421425
}
426+
427+
func isAttestationManifestDescriptor(desc ocispec.Descriptor) bool {
428+
const manifestReferenceType = "vnd.docker.reference.type"
429+
const attestationManifest = "attestation-manifest"
430+
return desc.Annotations[manifestReferenceType] == attestationManifest
431+
}

0 commit comments

Comments
 (0)