Skip to content

Commit

Permalink
ibcli: introduce/use manifestOptions struct
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mvo5 committed Jan 15, 2025
1 parent 5101f56 commit ccf24c9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
13 changes: 9 additions & 4 deletions cmd/image-builder/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,18 +107,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 {
Expand Down
18 changes: 12 additions & 6 deletions cmd/image-builder/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,35 @@ 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
}
// 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)
}

0 comments on commit ccf24c9

Please sign in to comment.