main: add --output-dir option

This commit adds a new `--output-dir` option to override the
default output directory for the generated artifacts.

Note that this can also be used together with `manifest` when
extra artifacts (like the sbom) is requested.
This commit is contained in:
Michael Vogt 2025-01-16 17:33:18 +01:00 committed by Simon de Vlieger
parent d485bc3a44
commit cc2d1ac692
4 changed files with 94 additions and 7 deletions

View file

@ -16,6 +16,7 @@ import (
)
type manifestOptions struct {
OutputDir string
BlueprintPath string
Ostree *ostree.ImageOptions
RpmDownloader osbuild.RpmDownloader
@ -46,7 +47,10 @@ func generateManifest(dataDir string, img *imagefilter.Result, output io.Writer,
RpmDownloader: opts.RpmDownloader,
}
if slices.Contains(opts.ExtraArtifacts, "sbom") {
outputDir := outputDirFor(img)
outputDir := opts.OutputDir
if outputDir == "" {
outputDir = outputDirFor(img)
}
if err := os.MkdirAll(outputDir, 0755); err != nil {
return err
}