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:
parent
f8ffa8a258
commit
44f27108b9
2 changed files with 21 additions and 10 deletions
|
|
@ -110,18 +110,23 @@ func cmdManifestWrapper(cmd *cobra.Command, args []string, w io.Writer, archChec
|
|||
return nil, err
|
||||
}
|
||||
|
||||
res, err := getOneImage(dataDir, distroStr, imgTypeStr, archStr)
|
||||
img, err := getOneImage(dataDir, distroStr, imgTypeStr, archStr)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if archChecker != nil {
|
||||
if err := archChecker(res.Arch.Name()); err != nil {
|
||||
if err := archChecker(img.Arch.Name()); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
err = generateManifest(dataDir, blueprintPath, res, w, ostreeImgOpts, rpmDownloader)
|
||||
return res, err
|
||||
opts := &manifestOptions{
|
||||
BlueprintPath: blueprintPath,
|
||||
Ostree: ostreeImgOpts,
|
||||
RpmDownloader: rpmDownloader,
|
||||
}
|
||||
err = generateManifest(dataDir, img, w, opts)
|
||||
return img, err
|
||||
}
|
||||
|
||||
func cmdManifest(cmd *cobra.Command, args []string) error {
|
||||
|
|
|
|||
|
|
@ -12,7 +12,13 @@ import (
|
|||
"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)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
@ -20,21 +26,21 @@ func generateManifest(dataDir, blueprintPath string, res *imagefilter.Result, ou
|
|||
// XXX: add --rpmmd/cachedir option like bib
|
||||
mg, err := manifestgen.New(repos, &manifestgen.Options{
|
||||
Output: output,
|
||||
RpmDownloader: rpmDownloader,
|
||||
RpmDownloader: opts.RpmDownloader,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
bp, err := blueprintload.Load(blueprintPath)
|
||||
bp, err := blueprintload.Load(opts.BlueprintPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
var imgOpts *distro.ImageOptions
|
||||
if ostreeOpts != nil {
|
||||
if opts.Ostree != nil {
|
||||
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)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue