main: tweak handling of --output-name to avoid adding double extensions
This commit tweaks the handling of the `--output-name` option so that is a name with the same extension as the image is passed that is just silently ignored. Its a common issue that first time users run: ```console $ image-builder build --output-name foo.qcow2 qcow2 ``` which currently leads to a foo.qcow2.qcow2. With this commit the expected "foo.qcow2" will appear.
This commit is contained in:
parent
d4c31389a9
commit
d00e76ced1
4 changed files with 46 additions and 4 deletions
|
|
@ -59,9 +59,7 @@ func generateManifest(dataDir string, extraRepos []string, img *imagefilter.Resu
|
|||
if opts.WithSBOM {
|
||||
outputDir := basenameFor(img, opts.OutputDir)
|
||||
manifestGenOpts.SBOMWriter = func(filename string, content io.Reader, docType sbom.StandardType) error {
|
||||
if opts.OutputFilename != "" {
|
||||
filename = fmt.Sprintf("%s.%s", opts.OutputFilename, strings.SplitN(filename, ".", 2)[1])
|
||||
}
|
||||
filename = fmt.Sprintf("%s.%s", basenameFor(img, opts.OutputFilename), strings.SplitN(filename, ".", 2)[1])
|
||||
return sbomWriter(outputDir, filename, content)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue