Commit graph

15 commits

Author SHA1 Message Date
Tomáš Hozza
3ac6d405b5 Fix pylint issue E0606: possibly-used-before-assignment
Fix:
assemblers/org.osbuild.qemu:310:36: E0606: Possibly using variable 'prep_type' before assignment (possibly-used-before-assignment)
inputs/org.osbuild.tree:85:15: E0606: Possibly using variable 'path' before assignment (possibly-used-before-assignment)
stages/org.osbuild.sfdisk:58:36: E0606: Possibly using variable 'prep_type' before assignment (possibly-used-before-assignment)
stages/org.osbuild.systemd.unit:23:16: E0606: Possibly using variable 'unit_dropins_dir' before assignment (possibly-used-before-assignment)
test/mod/test_meta.py:219:29: E0606: Possibly using variable 'schema_part' before assignment (possibly-used-before-assignment)

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2024-11-25 10:09:18 +01:00
Michael Vogt
4f4bddcc75 test: add "functional" test for devices/mounts acceptance
This test ensures that the inputs of devices/mounts we generate for
bootc are actually considered valid by the schema. This is a more
blackbox style test compared to `test_get_schema_automatically_added`
which just checks that we get the expected schema but not that the
expected schema actually parses our inputs.
2024-05-03 11:26:22 +02:00
Michael Vogt
659f1f06f2 meta: automatically allow devices as input in the stages schemas
With the new `bootc install to-filesystem` support many stages
will need a devices/mount setup to bind mount the deployment root
from the bootc deployment root of the generated image. To make
this globally available just allow "devices/mounts" for all stages
in the schema validation.

Note that `mounts` is already globally allowed so this just adds
devices (this was added in `7e776a076` with ostree as the use-case).
Nothing will change for the filesystem stages that already define
"devices" in a more specialized way.
2024-04-16 08:04:43 +02:00
Simon de Vlieger
6b4bb850a7 meta: ensure caps always a set
When loaded directly from JSON the caps are a list while they're
expected to be a set.
2024-03-19 15:32:45 +01:00
Simon de Vlieger
8f7d029e9f stage: schema allows for any of schema/schema_2
Instead of requiring only one of the properties to be present require at
least one of them being present; some stages specify both schema
versions (`org.osbuild.rpm`)
2024-03-19 15:32:45 +01:00
Michael Vogt
a7b4565445 meta: add tests for invalid python json/schema parsing
Based on the feedback from Tomáš in [0] this commit adds tests
that ensure consistent behavior between the python and the json
loader.

It's not 100% because the python is extremly leaniant and does
not even check if the required pieces of the json are there.
I.e. it will load a module without a SCHEMA or SCHEMA_2 variable
and the json loader code will warn about the issue but not
raise an error.

Fwiw, I have no strong opinion here but I do lean slightly towards
staying close to the original code (but both approaches of failing
with an exectption and continue with a warning have good arguments).

[0] https://github.com/osbuild/osbuild/pull/1618#discussion_r1521141148
2024-03-14 13:37:57 +01:00
Michael Vogt
9af7c9b279 meta: add .meta.json schema validation 2024-03-14 13:37:57 +01:00
Michael Vogt
3e11b57815 meta: rename -meta.json to .meta.json
With `.meta.json` it's two "real" file extension. The `-meta.json`
feels less clear.
2024-03-14 13:37:57 +01:00
Michael Vogt
9b09ed9eb4 osbuild: allow json data to come from a {stage}-meta.json file
Instead of always parsing the python stage to load meta information
allow the user of a new `{stage}-meta.json` file. This is a first
step towards allowing modules to be written in a different language
than python. It also has some practical advantages:
- slightly faster as it avoids calling python to output the schemas
- easier to write schemas as this can be done in a real json editor
  now
- more extensible in a future where stages maybe binaries with
  shlib dependencies that are only satisfied in the buildroot
  but not on the host
2024-03-14 13:37:57 +01:00
Michael Vogt
57b5c7994e test: fix all pylint issues 2024-01-02 19:31:31 +01:00
Michael Vogt
9d7bbd674f tests: remove custom tempdir_fixture
There is no need for a handcrafted tempdir fixture, pytest already
provides a build-in `tmp_path`.
2023-11-22 12:46:19 +01:00
Brian C. Lane
44c28c8c16 autopep8: Update with changes to make autopep8 -a -a -a happy 2023-08-10 13:04:14 +02:00
Christian Kellner
683a8cbfa7 meta: cache list of runners
Instead of enumerating all existing runners -- doing i/o -- we
cache the list at the `Index` level.
2022-10-11 12:49:16 +02:00
Christian Kellner
ec1c5bb37c test: checks for runner detection
Add a test suite for the runner detection logic.
2022-10-11 12:49:16 +02:00
Christian Kellner
49dc76c434 test: add new test suite for 'meta' module
Move the checks for `meta.Schema` from `test_osbuild.py` into the new
test suite, converting it to use pytest in the process.
2022-10-11 12:49:16 +02:00