Skip to content

feat: allow passing sbomDir to KO #5688

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Apr 11, 2025

Conversation

markussiebert
Copy link
Contributor

@markussiebert markussiebert commented Mar 28, 2025

This commit will allow passing the sbomDir option to KO.

From the KO documentation:

But you can prefer to write SBOM to disk by giving the --sbom-dir flag instead of uploading it to registry, and ko will decide the extension based on the format you defined in the --sbom flag and file name based on the import path of your project.

This is useful if you are creating prereleases/snapshots your sbom would be "lost" as it is only published to the local docker registry - and you might use gorelease/ko in your BuildPipelines without docker agent running.

refs https://github.com/orgs/goreleaser/discussions/5679
closes #5689

@pull-request-size pull-request-size bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Mar 28, 2025
@caarlos0 caarlos0 added the enhancement New feature or request label Mar 28, 2025
@caarlos0 caarlos0 requested a review from Copilot March 28, 2025 13:16
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

A PR to add support for specifying a custom directory for writing SBOM files when using KO.

  • Added a "sbom_dir" option in the YAML configuration documentation with a default of "out/sbom".
  • Introduced a new SBOMDir field in the Go configuration structure.
  • Updated the build options and corresponding tests to support passing the new SBOMDir option.

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

File Description
www/docs/customization/ko.md Added documentation for the new "sbom_dir" parameter with explanation and default value.
pkg/config/config.go Extended the configuration struct to include the SBOMDir field.
internal/pipe/ko/ko_test.go Updated tests to include scenarios for the new SBOMDir parameter.
internal/pipe/ko/ko.go Modified the build options logic to include SBOMDir when set and "spdx" is used.

Copy link
Member

@caarlos0 caarlos0 left a comment

Choose a reason for hiding this comment

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

hey! thanks for the PR

have just a couple of minor remarks in the docs!

@@ -416,6 +416,7 @@ type Ko struct {
CreationTime string `yaml:"creation_time,omitempty" json:"creation_time,omitempty"`
KoDataCreationTime string `yaml:"ko_data_creation_time,omitempty" json:"ko_data_creation_time,omitempty"`
SBOM string `yaml:"sbom,omitempty" json:"sbom,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

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

TODO to me: add the valid options of this to the JSONSchema

Copy link

codecov bot commented Mar 28, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.03%. Comparing base (1cecd11) to head (607d676).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5688      +/-   ##
==========================================
+ Coverage   83.01%   83.03%   +0.02%     
==========================================
  Files         158      158              
  Lines       15564    15583      +19     
==========================================
+ Hits        12920    12939      +19     
  Misses       2088     2088              
  Partials      556      556              

☔ 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.

@caarlos0 caarlos0 merged commit 4ac3076 into goreleaser:main Apr 11, 2025
18 checks passed
@caarlos0
Copy link
Member

Thank you!

caarlos0 added a commit that referenced this pull request Apr 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow passing the sbomDir to KO
2 participants