Skip to content

Commit a0eda92

Browse files
committed
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>
1 parent acb9ae0 commit a0eda92

5 files changed

Lines changed: 16 additions & 549 deletions

File tree

src/molecule/data/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"""Module containing molecule data files."""

src/molecule/data/molecule.json

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,8 @@
1313
"type": "object"
1414
},
1515
"MoleculeDependencyModel": {
16-
"additionalProperties": false,
16+
"unevaluatedProperties": false,
1717
"properties": {
18-
"command": {
19-
"title": "Command",
20-
"type": ["string", "null"]
21-
},
2218
"enabled": {
2319
"default": true,
2420
"title": "Enabled",
@@ -38,6 +34,17 @@
3834
"type": "object"
3935
}
4036
},
37+
"if": {
38+
"properties": { "name": { "const": "galaxy" } }
39+
},
40+
"then": {
41+
"properties": {
42+
"command": { "title": "Command", "type": ["string", "null"] }
43+
}
44+
},
45+
"else": {
46+
"properties": { "command": { "title": "Command", "type": "string" } }
47+
},
4148
"required": ["name"],
4249
"title": "MoleculeDependencyModel",
4350
"type": "object"
@@ -509,7 +516,7 @@
509516
"type": "object"
510517
}
511518
},
512-
"$id": "https://raw.githubusercontent.com/ansible/schemas/main/f/molecule.json",
519+
"$id": "https://raw.githubusercontent.com/ansible-community/molecule/main/src/molecule/data/molecule.json",
513520
"$schema": "http://json-schema.org/draft-07/schema",
514521
"additionalProperties": false,
515522
"examples": ["molecule/*/molecule.yml"],

src/molecule/model/schema_v3.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@
2525
from jsonschema import validate as jsonschema_validate
2626
from jsonschema.exceptions import ValidationError
2727

28-
from molecule.schemas import __file__ as schemas_module
28+
from molecule.data import __file__ as data_module
2929

3030

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

src/molecule/schemas/__init__.py

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)