ibcli: introduce/use manifestOptions struct

This commit adds a new manifestOptions struct that is passed
to generateManifest. to cleanup the signature of generateManifest().

This can then also be used to carry a new e.g. `--rpmmd/--cachedir`
option.
This commit is contained in:
Michael Vogt 2025-01-15 09:26:18 +01:00 committed by Simon de Vlieger
parent f8ffa8a258
commit 44f27108b9
2 changed files with 21 additions and 10 deletions

View file

@ -110,18 +110,23 @@ func cmdManifestWrapper(cmd *cobra.Command, args []string, w io.Writer, archChec
return nil, err return nil, err
} }
res, err := getOneImage(dataDir, distroStr, imgTypeStr, archStr) img, err := getOneImage(dataDir, distroStr, imgTypeStr, archStr)
if err != nil { if err != nil {
return nil, err return nil, err
} }
if archChecker != nil { if archChecker != nil {
if err := archChecker(res.Arch.Name()); err != nil { if err := archChecker(img.Arch.Name()); err != nil {
return nil, err return nil, err
} }
} }
err = generateManifest(dataDir, blueprintPath, res, w, ostreeImgOpts, rpmDownloader) opts := &manifestOptions{
return res, err BlueprintPath: blueprintPath,
Ostree: ostreeImgOpts,
RpmDownloader: rpmDownloader,
}
err = generateManifest(dataDir, img, w, opts)
return img, err
} }
func cmdManifest(cmd *cobra.Command, args []string) error { func cmdManifest(cmd *cobra.Command, args []string) error {

View file

@ -12,7 +12,13 @@ import (
"github.com/osbuild/image-builder-cli/internal/manifestgen" "github.com/osbuild/image-builder-cli/internal/manifestgen"
) )
func generateManifest(dataDir, blueprintPath string, res *imagefilter.Result, output io.Writer, ostreeOpts *ostree.ImageOptions, rpmDownloader osbuild.RpmDownloader) error { type manifestOptions struct {
BlueprintPath string
Ostree *ostree.ImageOptions
RpmDownloader osbuild.RpmDownloader
}
func generateManifest(dataDir string, img *imagefilter.Result, output io.Writer, opts *manifestOptions) error {
repos, err := newRepoRegistry(dataDir) repos, err := newRepoRegistry(dataDir)
if err != nil { if err != nil {
return err return err
@ -20,21 +26,21 @@ func generateManifest(dataDir, blueprintPath string, res *imagefilter.Result, ou
// XXX: add --rpmmd/cachedir option like bib // XXX: add --rpmmd/cachedir option like bib
mg, err := manifestgen.New(repos, &manifestgen.Options{ mg, err := manifestgen.New(repos, &manifestgen.Options{
Output: output, Output: output,
RpmDownloader: rpmDownloader, RpmDownloader: opts.RpmDownloader,
}) })
if err != nil { if err != nil {
return err return err
} }
bp, err := blueprintload.Load(blueprintPath) bp, err := blueprintload.Load(opts.BlueprintPath)
if err != nil { if err != nil {
return err return err
} }
var imgOpts *distro.ImageOptions var imgOpts *distro.ImageOptions
if ostreeOpts != nil { if opts.Ostree != nil {
imgOpts = &distro.ImageOptions{ imgOpts = &distro.ImageOptions{
OSTree: ostreeOpts, OSTree: opts.Ostree,
} }
} }
return mg.Generate(bp, res.Distro, res.ImgType, res.Arch, imgOpts) return mg.Generate(bp, img.Distro, img.ImgType, img.Arch, imgOpts)
} }