ibcli: don't split outputfilename

A small test for a basename that includes dotted parts (as used by for
example Fedora's buildsystem).

Also some code changes to make this test pass, it seems that SBOM base
was determined based on some other filename which is now no longer
relevant?

Signed-off-by: Simon de Vlieger <supakeen@redhat.com>
This commit is contained in:
Simon de Vlieger 2025-03-14 12:31:07 +01:00
parent b51d1f983a
commit e7b9fbff1e
2 changed files with 8 additions and 9 deletions

View file

@ -879,7 +879,7 @@ func TestBuildIntegrationOutputFilename(t *testing.T) {
"--distro", "centos-9",
"--cache", tmpdir,
"--output-dir", outputDir,
"--output-name=foo",
"--output-name=foo.n.0",
"--with-manifest",
"--with-sbom",
"--with-buildlog",
@ -894,11 +894,11 @@ func TestBuildIntegrationOutputFilename(t *testing.T) {
assert.NoError(t, err)
expectedFiles := []string{
"foo.buildroot-build.spdx.json",
"foo.image-os.spdx.json",
"foo.osbuild-manifest.json",
"foo.buildlog",
"foo.qcow2",
"foo.n.0.buildroot-build.spdx.json",
"foo.n.0.image-os.spdx.json",
"foo.n.0.osbuild-manifest.json",
"foo.n.0.buildlog",
"foo.n.0.qcow2",
}
files, err := filepath.Glob(outputDir + "/*")
assert.NoError(t, err)

View file

@ -56,10 +56,9 @@ func generateManifest(dataDir string, extraRepos []string, img *imagefilter.Resu
}
if opts.WithSBOM {
outputDir := basenameFor(img, opts.OutputDir)
overrideSBOMBase := strings.SplitN(opts.OutputFilename, ".", 2)[0]
manifestGenOpts.SBOMWriter = func(filename string, content io.Reader, docType sbom.StandardType) error {
if overrideSBOMBase != "" {
filename = fmt.Sprintf("%s.%s", overrideSBOMBase, strings.SplitN(filename, ".", 2)[1])
if opts.OutputFilename != "" {
filename = fmt.Sprintf("%s.%s", opts.OutputFilename, strings.SplitN(filename, ".", 2)[1])
}
return sbomWriter(outputDir, filename, content)
}