Skip to content

Commit

Permalink
Schema fix (ansible#3671)
Browse files Browse the repository at this point in the history
* Fix import of molecule schema.

Commit "Adopt molecule config JSON schema (ansible#3668)" (acb9ae0)
has imported the molecule schema into data/ but everything is using
src/molecule/schemas/ as directory for the schema.

So:
- Update src/molecule/data/molecule.json with parts of
  src/molecule/schemas/molecule.json content with the one. The update/
  replacement was partial as the local schema handles in a better way
  the MoleculeDependencyModel. The new schema was allowing to use the
  "shell" dependency with an empty command.
- Update schema $id to point to the correct location
- Fix test link to point to the correct schema file.
- Fix path to the schema in schema_v3.py

Signed-off-by: Arnaud Patard <apatard@hupstream.com>

* rc/molecule/test/unit/model/v2/test_dependency_section.py: Fix checks

With the new schema file, the schema check doesn't return the same
error strings, so update them.

Signed-off-by: Arnaud Patard <apatard@hupstream.com>

Signed-off-by: Arnaud Patard <apatard@hupstream.com>
  • Loading branch information
apatard authored and davedittrich committed Oct 24, 2022
1 parent fc348ba commit e8701fc
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 558 deletions.
1 change: 1 addition & 0 deletions src/molecule/data/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Module containing molecule data files."""
19 changes: 13 additions & 6 deletions src/molecule/data/molecule.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,8 @@
"type": "object"
},
"MoleculeDependencyModel": {
"additionalProperties": false,
"unevaluatedProperties": false,
"properties": {
"command": {
"title": "Command",
"type": ["string", "null"]
},
"enabled": {
"default": true,
"title": "Enabled",
Expand All @@ -38,6 +34,17 @@
"type": "object"
}
},
"if": {
"properties": { "name": { "const": "galaxy" } }
},
"then": {
"properties": {
"command": { "title": "Command", "type": ["string", "null"] }
}
},
"else": {
"properties": { "command": { "title": "Command", "type": "string" } }
},
"required": ["name"],
"title": "MoleculeDependencyModel",
"type": "object"
Expand Down Expand Up @@ -509,7 +516,7 @@
"type": "object"
}
},
"$id": "https://raw.githubusercontent.com/ansible/schemas/main/f/molecule.json",
"$id": "https://raw.githubusercontent.com/ansible-community/molecule/main/src/molecule/data/molecule.json",
"$schema": "http://json-schema.org/draft-07/schema",
"additionalProperties": false,
"examples": ["molecule/*/molecule.yml"],
Expand Down
4 changes: 2 additions & 2 deletions src/molecule/model/schema_v3.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@
from jsonschema import validate as jsonschema_validate
from jsonschema.exceptions import ValidationError

from molecule.schemas import __file__ as schemas_module
from molecule.data import __file__ as data_module


def validate(c):
"""Perform schema validation."""
result = []
schema_file = os.path.dirname(schemas_module) + "/molecule.json"
schema_file = os.path.dirname(data_module) + "/molecule.json"
with open(schema_file, encoding="utf-8") as f:
schema = json.load(f)

Expand Down
1 change: 0 additions & 1 deletion src/molecule/schemas/__init__.py

This file was deleted.

Loading

0 comments on commit e8701fc

Please sign in to comment.