New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace cerberus with jsonschema for configuration validation #3638
Replace cerberus with jsonschema for configuration validation #3638
Conversation
@zhan9san Thanks for working on this, that is indeed a very helpful change. I did not look into details but it makes sense to remove lots of tests that no longer apply to use of json-schema. I do totally agree that we should move some of the schemas inside the projects themselves. In fact I was planning to do the same for ansible-lint and ansible-navigator, as these are quite simple. There is no more authoritative source for managing a schema than the project using it. There is still one areas that worries me, is the use of a newer draft spec and basically because these schemas are using by vscode-yaml extension, which does not support the latest drafts. We must be sure that we do not start to use features that are not yet supported by it or we will break it. |
If someone can take a look on this change it would be awesome. What is the impact on current plugins? Are they going to break and will need to be fixed? |
This breaks molecule-vmware in several places:
This seems easily fixable by moving the config to the
Having this enum seems like a really bad idea to me, since it will be a showstopper for every new driver being developed. I would therefore suggest, either making this only a warning, or remove it altogether. |
Please have a look at #3689, which, I guess, is the same problem. |
This seems to break delegated drivers, how can we extend the schema? |
Have you tried the latest version? The delegated driver is in the allowed list. |
Yep I'm on the latest release, v4.0.3. ---
driver:
name: delegated
options:
managed: true
foreman_fqdn: https://my.foreman.server
foreman_validate_certs: false
foreman_ssh_user: root
foreman_ssh_port: 22
foreman_ssh_job_template_name: "Ansible Roles - Single Role"
foreman_ssh_job_template_input:
- key: "ansible_role"
value: "example.role" The Error I get is: |
Fixes: #3637 Remove
cerberus
, usejsonschema
instead.@ssbarnea
Could you kindly review this PR?
I tried to make this PR smaller, but it seems not.
Feel free to leave your comments.
Schema Definition
As the definition of schemas between
cerberus
andjsonschema
are different, all schemas are redefined and consolidated into onesrc/molecule/schemas/molecule.json
.ansible-lint
will sync the schemas from https://github.com/ansible/schemas, but formolecule
, I think there is no need to sync it from another repo. Sosrc/molecule/schemas/molecule.json
makes the maintenance convenient.JSON Schema
ansible-lint
: "http://json-schema.org/draft-07/schema",https://json-schema.org/draft/2020-12/schema
is used in this PR.This new draft supports Unevaluated Properties, and it has more power than
additionalProperties
.So it is used in
MoleculeDependencyModel
schema._preflight
_preflight
and related test functions are deleted as well, because I think it is redundant.Validation Errors
For simplicity, only the first error would be showed. It is not user-friendly.
But currently, the PR is too big to review, so I suggest we can optimize it later to show all errors via
iter_errors
, if needed.Unit test
Some unit tests are deleted for simplicity. We can add more in another PR, if needed.