Repository navigation
osbuild: compare Go against JSON - #2529
Conversation
New test that parses the Go implementation of the `osbuild` stages using the `ast` module (this was quite a bit of work, but surprisingly straightforward even if verbose). Ensures types in the JSON files match types in the Go files, including any type aliases. Outputs informational bits about missing properties on the Go side or osbuild side. Outputs information about stages that in osbuild that do not have any Go counterpart. Does *not* properly validate `anyOf`/`enum`/etc. But this basic validation is already helpful and followups are very possible. By default looks in `/usr/lib/osbuild`; if no stages can be found the test is skipped. Custom directory can be passed through `TEST_OSBUILD_STAGES_DIR`. Signed-off-by: Simon de Vlieger <[email protected]>
f69744f to
5e94b00
Compare
|
A commit title like 'osbuild: Verify stage metadata JSON' might be better. Just looking at the title I wasn't sure what was going on until I read the description :) |
|
This is a bit too complex, even for a test. There are existing JSON Schema Go libraries with validation capabilities, if we really need to validate any kind of JSON data, we can and much more easily. As long as we plug that into our existing serialization tests, we get the job done with much less code. |
|
This PR is stale because it had no activity for the past 30 days. Remove the "Stale" label or add a comment, otherwise this PR will be closed in 7 days. |
avitova
left a comment
There was a problem hiding this comment.
It can be nice to have a basic check. My main concern is a false sense of security, since it does not check of allOf schema blocks, and defaults to true on some places. But unless we rely on this too much, looks good.
New test that parses the Go implementation of the
osbuildstages using theastmodule (this was quite a bit of work, but surprisingly straightforward even if verbose).Ensures types in the JSON files match types in the Go files, including any type aliases.
Outputs informational bits about missing properties on the Go side or osbuild side. Outputs information about stages that in osbuild that do not have any Go counterpart.
Does not properly validate
anyOf/enum/etc. But this basic validation is already helpful and followups are very possible.By default looks in
/usr/lib/osbuild; if no stages can be found the test is skipped. Custom directory can be passed throughTEST_OSBUILD_STAGES_DIR.Example (verbose) output: