mounts: change schema meta information

Define the mount schema in the actual mounts at a higher level. This
is in preparation to give the modules more control over the `source`
and `target` properties.
This commit is contained in:
Christian Kellner 2021-10-18 16:39:22 +02:00 committed by Tom Gundersen
parent 5694743ca6
commit 02404ced94
6 changed files with 92 additions and 11 deletions

View file

@ -13,8 +13,23 @@ from typing import Dict
from osbuild import mounts
SCHEMA = """
"additionalProperties": False
SCHEMA_2 = """
"additionalProperties": false,
"required": ["name", "type", "source", "target"],
"properties": {
"name": { "type": "string" },
"type": { "type": "string" },
"source": {
"type": "string"
},
"target": {
"type": "string"
},
"options": {
"type": "object",
"additionalProperties": true
}
}
"""

View file

@ -13,8 +13,23 @@ from typing import Dict
from osbuild import mounts
SCHEMA = """
"additionalProperties": false
SCHEMA_2 = """
"additionalProperties": false,
"required": ["name", "type", "source", "target"],
"properties": {
"name": { "type": "string" },
"type": { "type": "string" },
"source": {
"type": "string"
},
"target": {
"type": "string"
},
"options": {
"type": "object",
"additionalProperties": true
}
}
"""

View file

@ -13,8 +13,23 @@ from typing import Dict
from osbuild import mounts
SCHEMA = """
"additionalProperties": false
SCHEMA_2 = """
"additionalProperties": false,
"required": ["name", "type", "source", "target"],
"properties": {
"name": { "type": "string" },
"type": { "type": "string" },
"source": {
"type": "string"
},
"target": {
"type": "string"
},
"options": {
"type": "object",
"additionalProperties": true
}
}
"""

View file

@ -15,8 +15,23 @@ from typing import Dict
from osbuild import mounts
SCHEMA = """
"additionalProperties": false
SCHEMA_2 = """
"additionalProperties": false,
"required": ["name", "type", "source", "target"],
"properties": {
"name": { "type": "string" },
"type": { "type": "string" },
"source": {
"type": "string"
},
"target": {
"type": "string"
},
"options": {
"type": "object",
"additionalProperties": true
}
}
"""

View file

@ -13,8 +13,23 @@ from typing import Dict
from osbuild import mounts
SCHEMA = """
"additionalProperties": false
SCHEMA_2 = """
"additionalProperties": false,
"required": ["name", "type", "source", "target"],
"properties": {
"name": { "type": "string" },
"type": { "type": "string" },
"source": {
"type": "string"
},
"target": {
"type": "string"
},
"options": {
"type": "object",
"additionalProperties": true
}
}
"""

View file

@ -332,13 +332,19 @@ class ModuleInfo:
**opts,
}
schema["required"] = [type_id]
elif self.type in ("Device", "Mount"):
elif self.type in ("Device"):
schema["additionalProperties"] = True
opts = self._load_opts(version, "1")
schema["properties"] = {
"type": {"enum": [self.name]},
"options": opts
}
elif self.type in ("Mount"):
opts = self._load_opts("2")
schema.update(opts)
schema["properties"]["type"] = {
"enum": [self.name],
}
else:
opts = self._load_opts(version, "1")
schema.update(opts)