#
4f93bb8c |
| 04-Sep-2024 |
Patrick Williams <patrick@stwcx.xyz> |
jsonschema: update validator to the latest draft
The JSON Schema "draft 7" is now old and the latest is "2020-12". Switch the validator object we use to be the latest version.
Signed-off-by: Patri
jsonschema: update validator to the latest draft
The JSON Schema "draft 7" is now old and the latest is "2020-12". Switch the validator object we use to be the latest version.
Signed-off-by: Patrick Williams <patrick@stwcx.xyz> Change-Id: I90a0d9b8669bade600ca3d48041f31727e410e14
show more ...
|
#
183fab9d |
| 19-Mar-2024 |
Andrew Jeffery <andrew@codeconstruct.com.au> |
scripts/validate_configs.py: Ensure schemas are validated as well
The quick'n'dirty method of validating a schema is via `jsonschema.validate()`. From `help(jsonschema.validate)` we have:
> :func
scripts/validate_configs.py: Ensure schemas are validated as well
The quick'n'dirty method of validating a schema is via `jsonschema.validate()`. From `help(jsonschema.validate)` we have:
> :func:`validate` will first verify that the provided schema is > itself valid, since not doing so can lead to less obvious error > messages and fail in less obvious or consistent ways. > > If you know you have a valid schema already, especially if you > intend to validate multiple instances with the same schema, you > likely would prefer using the `Validator.validate` method directly > on a specific validator (e.g. ``Draft7Validator.validate``).
The implication is that explicitly instantiating a validator does not validate the provided schema.
The implementation of validate_configs.py directly instantiates the Draft7Validator() in order to provide a RefResolver. However, it does not do the required work of validating the provided schema.
Rework the code instantiating the validator to validate the schema prior to use.
Tested:
``` $ git revert -n $(git log --grep 'I2b8102e7d6047c8a7e624e182465065268fb8ad9' --format='%H') && ./scripts/validate_configs.py -v -k; git reset --hard Traceback (most recent call last): File "/home/andrew/src/openbmc.org/openbmc/entity-manager/origin/./scripts/validate_configs.py", line 187, in <module> main() File "/home/andrew/src/openbmc.org/openbmc/entity-manager/origin/./scripts/validate_configs.py", line 138, in main spec.check_schema(schema) File "/usr/lib/python3/dist-packages/jsonschema/validators.py", line 204, in check_schema raise exceptions.SchemaError.create_from(error) jsonschema.exceptions.SchemaError: ['The schema for an entity manager configuration file. An entity ', 'mananger configuration file can consist of a single object, or an ', 'array of objects. Objects must be of type EMConfig.'] is not of type 'string'
Failed validating 'type' in metaschema['properties']['description']: {'type': 'string'}
On schema['description']: ['The schema for an entity manager configuration file. An entity ', 'mananger configuration file can consist of a single object, or an ', 'array of objects. Objects must be of type EMConfig.'] HEAD is now at cecbd8129645 scripts/validate_configs.py: Ensure schemas are validated as well ```
Change-Id: Ib4d41c0f7a07c1ea4b9a483893969f21870a50e1 Signed-off-by: Andrew Jeffery <andrew@codeconstruct.com.au>
show more ...
|
#
0f3a4d99 |
| 04-Dec-2023 |
Potin Lai <potin.lai@quantatw.com> |
Support C-style comments for configuration JSON parsing
1. Add and set ignore_comment to true to all nlohmann::json::parse(). 2. Add remove_c_comments() in `validate_configs.py` to remove C-style
Support C-style comments for configuration JSON parsing
1. Add and set ignore_comment to true to all nlohmann::json::parse(). 2. Add remove_c_comments() in `validate_configs.py` to remove C-style comments before loading. 3. Attempt to reformat comments in the `autojson.py` taking liberal short-cuts which are documented in the script.
Supported comment examples:
- Single-line style comments ``` { // Single-line style comment (new line) "Key": "Value" // Single-line comment (end of content) } ```
- Multi-line style comments ``` { /* Multi-line style comment */ /* * Multi-line style comments */ } ```
Tested on harma system with manual applied patch below, which contains a c-style comment in harma-pttv.json file. Link: https://gerrit.openbmc.org/c/openbmc/entity-manager/+/67469/25
- scripts/autojson.py Run autojson.py on harma-pttv.json, the output as same as original file.
- scripts/validate_configs.py Run validate_configs.py passed.
- EntityManager service EntityManager service loads and probes harma-pttv.json successfully. ``` root@harma:~# busctl introspect xyz.openbmc_project.EntityManager \ > /xyz/openbmc_project/inventory/system/board/Harma_PTTV \ > xyz.openbmc_project.Inventory.Item.Board NAME TYPE SIGNATURE RESULT/VALUE FLAGS .Name property s "Harma PTTV" emits-change .Probe property s "xyz.openbmc_project.FruDevice({\'BOA... emits-change .Type property s "Board" emits-change ```
Signed-off-by: Potin Lai <potin.lai@quantatw.com> Signed-off-by: Patrick Williams <patrick@stwcx.xyz> Change-Id: Ib235f2aa6a724615dc4c8184577f57abda8e17a6
show more ...
|
#
fa8ee87e |
| 07-Dec-2022 |
Patrick Williams <patrick@stwcx.xyz> |
format: reformat with latest openbmc-build-scripts
Run all the latest formatters from openbmc-build-scripts. Disable prettier on the configurations subdirectory because these are script-formatted a
format: reformat with latest openbmc-build-scripts
Run all the latest formatters from openbmc-build-scripts. Disable prettier on the configurations subdirectory because these are script-formatted already with the repo-local `format-code` extension.
Signed-off-by: Patrick Williams <patrick@stwcx.xyz> Change-Id: Ifa4f2ec6688d60fde2a5f42efc96b6046e9be642
show more ...
|
#
bfc7296e |
| 26-May-2022 |
Brad Bishop <bradleyb@fuzziesquirrel.com> |
scripts: use lower_snake_case for filenames
To be consistent with lower_snake_case source code filenames, use lower_snake_case for scripts file names as well.
run-ci.sh is not renamed because openb
scripts: use lower_snake_case for filenames
To be consistent with lower_snake_case source code filenames, use lower_snake_case for scripts file names as well.
run-ci.sh is not renamed because openbmc-build-scripts specifically looks for run-ci.sh or run-ci.
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com> Change-Id: I4535bac41375d2c78e71da5020cb5e2410ff3eaa
show more ...
|