Skip to content
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

Determine SPDX license from command line (+bug fix) #2242

Merged
merged 2 commits into from
Sep 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions cmd/bom/cmd/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ type generateOptions struct {
namespace string
outputFile string
configFile string
license string
images []string
tarballs []string
files []string
Expand Down Expand Up @@ -156,6 +157,14 @@ func init() {
"list of regexp patterns to ignore when scanning directories",
)

generateCmd.PersistentFlags().StringVarP(
&genOpts.license,
"license",
"l",
"",
"SPDX license identifier to declare in the SBOM",
)

generateCmd.PersistentFlags().BoolVar(
&genOpts.noGitignore,
"no-gitignore",
Expand Down Expand Up @@ -228,6 +237,7 @@ func generateBOM(opts *generateOptions) error {
ProcessGoModules: !opts.noGoModules,
OnlyDirectDeps: !opts.noGoTransient,
ConfigFile: opts.configFile,
License: opts.license,
}

// We only replace the ignore patterns one or more where defined
Expand Down
4 changes: 2 additions & 2 deletions pkg/spdx/implementation.go
Original file line number Diff line number Diff line change
Expand Up @@ -565,8 +565,8 @@ func (di *spdxDefaultImplementation) ImageRefToPackage(ref string, opts *Options
FullRender: true,
Comment: "Container image lager",
})
pkg.AddRelationship(&Relationship{
Peer: subpkg,
subpkg.AddRelationship(&Relationship{
Peer: pkg,
Type: VARIANT_OF,
Comment: "Image index",
})
Expand Down