Skip to content

Conversation

@cmurphy
Copy link
Contributor

@cmurphy cmurphy commented Oct 25, 2025

Without this change, --upload=false was not respected with the new bundle format. It also would not have made sense because there was no way to output the bundle locally. This change adds a flag --output-bundle so that the bundle can be created on disk without attaching it to the image, and also passes through the Upload parameter to bypass uploading it if desired.

Fixes #4474

Summary

Release Note

Documentation

@cmurphy cmurphy requested a review from a team as a code owner October 25, 2025 00:38
@codecov
Copy link

codecov bot commented Oct 25, 2025

Codecov Report

❌ Patch coverage is 7.14286% with 39 lines in your changes missing coverage. Please review.
✅ Project coverage is 36.66%. Comparing base (2ef6022) to head (4450852).
⚠️ Report is 572 commits behind head on main.

Files with missing lines Patch % Lines
cmd/cosign/cli/signcommon/common.go 0.00% 17 Missing ⚠️
cmd/cosign/cli/attest/attest.go 0.00% 9 Missing ⚠️
cmd/cosign/cli/sign/sign.go 0.00% 9 Missing ⚠️
cmd/cosign/cli/options/sign.go 0.00% 3 Missing ⚠️
cmd/cosign/cli/attest/attest_blob.go 75.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4499      +/-   ##
==========================================
- Coverage   40.10%   36.66%   -3.44%     
==========================================
  Files         155      220      +65     
  Lines       10044    12150    +2106     
==========================================
+ Hits         4028     4455     +427     
- Misses       5530     7007    +1477     
- Partials      486      688     +202     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Member

@steiza steiza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few minor comments, otherwise LGTM. Holding off on approving until you have a chance to respond (and don't forget to run make docgen!)

Comment on lines 101 to 102
cmd.Flags().StringVar(&o.OutputBundle, "output-bundle", "",
"write the bundle to FILE")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: in sign-blob and attest-blob we just call this --bundle. Arguably --output-bundle is more descriptive, but --bundle would be more consistent. I slightly lean towards consistency here, but open to other opinions.

Separately, taking inspiration from sign-blob maybe the description could be something like:

write everything required to verify the image to a FILE


if c.SigningConfig != nil {
return signcommon.WriteNewBundleWithSigningConfig(ctx, c.KeyOpts, c.CertPath, c.CertChainPath, payload, digest, types.CosignSignPredicateType, "", c.SigningConfig, c.TrustedMaterial, ociremoteOpts...)
return signcommon.WriteNewBundleWithSigningConfig(ctx, c.KeyOpts, c.CertPath, c.CertChainPath, payload, digest, types.CosignSignPredicateType, "", !c.NoUpload, c.SigningConfig, c.TrustedMaterial, ociremoteOpts...)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: this is starting to be a lot of arguments to the signcommon.Write* functions! I'm fairly new to Go, but I think the idiomatic thing would be at some point to move these into a signcommon.WriteBundleWithSigningConfigOptions or some such. I'm not convinced this has to change in this pull request though, because this is an internal method that's easy to refactor later if needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a second commit to create a separate struct for these functions.

Without this change, --upload=false was not respected with the new
bundle format. It also would not have made sense because there was no
way to output the bundle locally. This change adds a flag
--bundle so that the bundle can be created on disk without
attaching it to the image, and also passes through the Upload parameter
to bypass uploading it if desired.

Signed-off-by: Colleen Murphy <[email protected]>
Use a common options struct for WriteBundle and
WriteNewBundleWithSigningConfig to reduce the number of arguments in
each function.

Signed-off-by: Colleen Murphy <[email protected]>
Copy link
Contributor

@haydentherapper haydentherapper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Should we also add the --bundle flag to cosign attest for uniformity?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

--upload=false doesn't work in cosign v3

3 participants