Commit graph

21 commits

Author SHA1 Message Date
Michael Vogt
5fb17b967e image-builder: use github.com/osbuild/blueprint
Drop using the "images" library blueprint types and use the ones
from github.com/osbuild/blueprint/pkg/blueprint instead.

This also moves to the images library to v0.172.0 and the blueprints
library to v1.12.0 as this is required for this to work.
2025-08-07 16:56:35 +00:00
Michael Vogt
ad20533d87 testutil: rename Calls() -> CallArgsList() for clarity
The current MockCmd.Calls() is a bit ambiguous so follow the example
of pytest here and rename to the cleaner CallArgsList() that
captures more closely what the helper is actually doing.
2025-07-17 06:44:29 +00:00
Michael Vogt
bb45b89d84 testutil: remove unnecessary testutil.MockCmd.Restore()
While looking over the code I noticed that the `Restore()` helper
is not needed (and arguably wrong as it does not reset PATH).
We already use `t.TempDir()` and `t.Setenv()` as part of the
command setup so manually cleanup is not neccessary (and is today
even incomplete). So YAGNI and we can remove Restore().
2025-07-17 06:44:29 +00:00
Lukas Zapletal
392a04fd12 refactor: use standard logger instead of logrus 2025-05-12 18:21:37 +00:00
Michael Vogt
a2f71ad44c Reapply "blueprintload: enable strict checking for toml"
This reverts commit f25b5e325e.
2025-04-09 05:32:45 +00:00
Simon de Vlieger
f25b5e325e Revert "blueprintload: enable strict checking for toml"
This reverts commit d41bd9aa5b.

Signed-off-by: Simon de Vlieger <supakeen@redhat.com>
2025-03-28 16:05:11 +00:00
Michael Vogt
2895e71064 many: move to use the new github.com/osbuild/blueprint module
This commit moves ibcli over to use the new `osbuild/blueprint`
module for better compatibility with the composer and on-prem
blueprints.
2025-03-27 11:59:45 +00:00
Michael Vogt
d41bd9aa5b blueprintload: enable strict checking for toml
Add strict checking for toml keys in blueprints. This allows us
to error early if there are unknown keys in a toml blueprint and
helps our users by spotting e.g. typos early.

This is similar to
https://github.com/osbuild/bootc-image-builder/pull/549
(thanks Ondrej!).
2025-03-25 19:13:33 +00:00
Michael Vogt
2f0caddf91 testutil: add testutil.Chdir() helper
A tiny helper to run a specific function inside a different dir,
useful in our testsuite.
2025-03-14 14:47:36 +00:00
Michael Vogt
e41cf0e429 testutil: add new CaptureStdio helper
This commit adds a new testutil.CaptureStdio helper so that we
can test external go modules that use os.Std{out,err} but now
allow mocking or overwriting.
2025-01-29 15:21:33 +00:00
Michael Vogt
98e4bebcfa image-builder: drop internal manifestgen in favor of images
This commit drops the internal `manifestgen` package in favor
of using the version in `images` now that
https://github.com/osbuild/images/pull/1153 is merged.
2025-01-27 10:14:53 +00:00
Michael Vogt
d485bc3a44 ibcli: add new --extra-artifacts option with sbom support
This commit adds an option --extra-artifacts that can be
used to generate extra artifacts during the build or manifest
generation. Initially supported is `sbom` (but `manifest` is
planned too).

To use it run `--extra-artifacts=sbom` and it will generate
files like `centos-9-qcow2-x86_64.image-os.spdx.json` in
the output directory next to the generate runable artifact.

Closes: https://github.com/osbuild/image-builder-cli/issues/46
2025-01-19 21:57:14 +00:00
Michael Vogt
d75bb4fa0a manifestgen: make depsolve return the full dnfjson.DepsolveResult
This commit changes the signature of depsolve in `manifestgen`
to return the full `dnfjson.DepsolveResult`. This gives us
access to the sbom and also is a preparation for images PR#1142
where we will need this anyway.
2025-01-17 13:29:01 +00:00
Michael Vogt
f8ffa8a258 main: add experimental --use-librepo to support librepo downloads
This commit switches to the librepo enabled `images` library via:
```
go mod -replace github.com/osbuild/iamges=github.com/mvo5/images@librepo-sources-osbuild1974
```
which in turn needs osbuild PR#1974.

With that it then adds a new `--use-librepo` switch that will
enable librepo based downloading so that people can play with
the new backend.
2025-01-17 13:29:01 +00:00
Michael Vogt
4f1816c1b7 manifestgen: pass missing repoConfig to preManifest.Serialize()
When depsolve is run it returns a list of packageSpecs and the
matching repository config. This repo config is different/distinct
from the repository config that is passed into depsolve via the
package sets or the repositories that are loaded via the
reporegistry and needs to be passed into `manifest.Serialize()`.

The key different is that the depsovle `repoConfig` contains
the repo.Id that match the packageSpec.RepoId. With those two
matching IDs we can use librepo (see osbuild PR#1974) to infere
what mirror to use for what package.

This commit now passes the correct repoConfig into
preManifest.Serialize() now.

No test (sorry!) as this is really hard to test in isolation, there
is nothing observable today from repoConfig and it is impossible
to add a "witness" pipelien that could check that the right argument
is passed in `pipeline.serializeStart()`. So until we refactor
images you will have to take my word for this (sorry again).
2025-01-10 13:49:28 +00:00
Michael Vogt
d727d9aa76 manifestgen: port to the new images manifest seed
This moves to the new images Manifest() API from PR#1107.
2025-01-08 06:53:12 +00:00
Michael Vogt
058e3d6832 manifestgen: use temporary cache dir if no cacheDir is given
This commit creates a temporary directory for the defaultDepvolver()
if no cacheDir is given. This ensures that we do not clutter the
current working directory with `platform:foo` cache directories
that `solver.Depvolve()` creates.

Note that this is only tested indirectly via the integration test
in `test_container.py:test_container_builds_image()` that checks
that the output directory is clean.
2024-12-19 08:49:26 +00:00
Michael Vogt
ce8dd45821 testutil: new package to test run osbuild run functionality
This commit adds a new testutil.MockCommand() helper that will
mock a command in $PATH to allow easier testing of e.g. the
`image-builder-cli build` comamnd that will invoke osbuild.
2024-12-16 14:59:08 +00:00
Michael Vogt
f242005672 internal: add new blueprintload package
This commit provides a `blueprintload` package that can be used
to load blueprints from json/toml from a path. This will be used
in `bootc-image-builder` and `image-builder-cli` and should
eventually be merged into `images`.
2024-12-16 07:54:45 +00:00
Michael Vogt
ea61ef593f pkg: add new manifestgen package
This commit adds a new generic `manifestgen` package that can be
used to generate osbuild manifests. It works on a higher level
then the low-level `manifest` package from `images` and provides
plugable resolvers and a streamlined API.

This package is meant to be moved to the `images` library eventually.
2024-12-16 07:54:45 +00:00
Michael Vogt
5a6ee5c1ca pkg: add new manifesttest package with test helpers
This commit adds a new `manifesttest` that helps sharing code
when testing generated osbuild manifests.
2024-12-16 07:54:45 +00:00