image-builder: slight cleanup

Remove all slice operations.

Co-authored-by: Michael Vogt <michael.vogt@gmail.com>
Signed-off-by: Simon de Vlieger <supakeen@redhat.com>
This commit is contained in:
Simon de Vlieger 2025-01-20 16:12:48 +01:00
parent d1fe1f9df7
commit 613f56e7d2
2 changed files with 11 additions and 18 deletions

View file

@ -133,18 +133,12 @@ func cmdManifestWrapper(cmd *cobra.Command, args []string, w io.Writer, archChec
}
}
var extraArtifacts []string
if withSBOM {
extraArtifacts = append(extraArtifacts, "sbom")
}
opts := &manifestOptions{
OutputDir: outputDir,
BlueprintPath: blueprintPath,
Ostree: ostreeImgOpts,
RpmDownloader: rpmDownloader,
ExtraArtifacts: extraArtifacts,
OutputDir: outputDir,
BlueprintPath: blueprintPath,
Ostree: ostreeImgOpts,
RpmDownloader: rpmDownloader,
WithSBOM: withSBOM,
}
err = generateManifest(dataDir, img, w, opts)
return img, err

View file

@ -4,7 +4,6 @@ import (
"io"
"os"
"path/filepath"
"slices"
"github.com/osbuild/images/pkg/distro"
"github.com/osbuild/images/pkg/imagefilter"
@ -16,11 +15,11 @@ import (
)
type manifestOptions struct {
OutputDir string
BlueprintPath string
Ostree *ostree.ImageOptions
RpmDownloader osbuild.RpmDownloader
ExtraArtifacts []string
OutputDir string
BlueprintPath string
Ostree *ostree.ImageOptions
RpmDownloader osbuild.RpmDownloader
WithSBOM bool
}
func sbomWriter(outputDir, filename string, content io.Reader) error {
@ -46,7 +45,7 @@ func generateManifest(dataDir string, img *imagefilter.Result, output io.Writer,
Output: output,
RpmDownloader: opts.RpmDownloader,
}
if slices.Contains(opts.ExtraArtifacts, "sbom") {
if opts.WithSBOM {
outputDir := opts.OutputDir
if outputDir == "" {
outputDir = outputNameFor(img)