schema/v2: make mount source and target optional
The previous commit gave the individual mounts more control over the source and target properties. Do not require them at the global schema but hand the control if they are optional over to the modules.
This commit is contained in:
parent
02404ced94
commit
5b1cd2b1c5
3 changed files with 12 additions and 8 deletions
|
|
@ -274,14 +274,16 @@ def load_mount(description: Dict, index: Index, stage: Stage):
|
||||||
if name in stage.mounts:
|
if name in stage.mounts:
|
||||||
raise ValueError(f"Duplicated mount '{name}'")
|
raise ValueError(f"Duplicated mount '{name}'")
|
||||||
|
|
||||||
source = description["source"]
|
source = description.get("source")
|
||||||
target = description["target"]
|
target = description.get("target")
|
||||||
|
|
||||||
options = description.get("options", {})
|
options = description.get("options", {})
|
||||||
|
|
||||||
device = stage.devices.get(source)
|
device = None
|
||||||
if not device:
|
if source:
|
||||||
raise ValueError(f"Unknown device '{source}' for mount '{name}'")
|
device = stage.devices.get(source)
|
||||||
|
if not device:
|
||||||
|
raise ValueError(f"Unknown device '{source}' for mount '{name}'")
|
||||||
|
|
||||||
stage.add_mount(name, info, device, target, options)
|
stage.add_mount(name, info, device, target, options)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,8 +35,10 @@ class Mount:
|
||||||
def calc_id(self):
|
def calc_id(self):
|
||||||
m = hashlib.sha256()
|
m = hashlib.sha256()
|
||||||
m.update(json.dumps(self.info.name, sort_keys=True).encode())
|
m.update(json.dumps(self.info.name, sort_keys=True).encode())
|
||||||
m.update(json.dumps(self.device.id, sort_keys=True).encode())
|
if self.device:
|
||||||
m.update(json.dumps(self.target, sort_keys=True).encode())
|
m.update(json.dumps(self.device.id, sort_keys=True).encode())
|
||||||
|
if self.target:
|
||||||
|
m.update(json.dumps(self.target, sort_keys=True).encode())
|
||||||
m.update(json.dumps(self.options, sort_keys=True).encode())
|
m.update(json.dumps(self.options, sort_keys=True).encode())
|
||||||
return m.hexdigest()
|
return m.hexdigest()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -71,7 +71,7 @@
|
||||||
"mount": {
|
"mount": {
|
||||||
"title": "Mount point for a stage",
|
"title": "Mount point for a stage",
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
"required": ["name", "type", "source", "target"],
|
"required": ["name", "type"],
|
||||||
"properties": {
|
"properties": {
|
||||||
"name": { "type": "string" },
|
"name": { "type": "string" },
|
||||||
"type": { "type": "string" },
|
"type": { "type": "string" },
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue