Skip to content

Commit ec447ac

Browse files
committed
Split up error messages for missing --sbom related flags
Split up the diagnostic for missing SBOM generation settings so that we can more easily tell the difference between "you didn't tell me where to put the output files" and "I don't know how to generate things". [NO NEW TESTS NEEDED] Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
1 parent bec7a14 commit ec447ac

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

pkg/parse/parse.go

+5-2
Original file line numberDiff line numberDiff line change
@@ -814,8 +814,11 @@ func SBOMScanOptionsFromFlagSet(flags *pflag.FlagSet, findFlagFunc func(name str
814814
return nil, fmt.Errorf("invalid value for --sbom-purl-output: %w", err)
815815
}
816816

817-
if options.Image == "" || len(options.Commands) == 0 || (options.SBOMOutput == "" && options.ImageSBOMOutput == "" && options.PURLOutput == "" && options.ImagePURLOutput == "") {
818-
return options, fmt.Errorf("sbom configuration missing one or more of (%q, %q, %q, %q, %q or %q)", "--sbom-scanner-imag", "--sbom-scanner-command", "--sbom-output", "--sbom-image-output", "--sbom-purl-output", "--sbom-image-purl-output")
817+
if options.Image == "" || len(options.Commands) == 0 {
818+
return options, fmt.Errorf("sbom configuration missing one or more of (%q or %q)", "--sbom-scanner-image", "--sbom-scanner-command")
819+
}
820+
if options.SBOMOutput == "" && options.ImageSBOMOutput == "" && options.PURLOutput == "" && options.ImagePURLOutput == "" {
821+
return options, fmt.Errorf("sbom configuration missing one or more of (%q, %q, %q or %q)", "--sbom-output", "--sbom-image-output", "--sbom-purl-output", "--sbom-image-purl-output")
819822
}
820823
if len(options.Commands) > 1 && options.MergeStrategy == "" {
821824
return options, fmt.Errorf("sbom configuration included multiple %q values but no %q value", "--sbom-scanner-command", "--sbom-merge-strategy")

0 commit comments

Comments
 (0)