Commit 6e8edc27 authored by Jérome Perrin's avatar Jérome Perrin

software/{kvm,theia}: use unevaluatedProperties for schema composition

This is based on example from https://json-schema.org/understanding-json-schema/reference/object#unevaluatedproperties
this approach allows extending a schema from another software type with
some extra properties while rejecting other properties on instances,
like it's done with additionalProperties: false.
parent d170acc7
Pipeline #36530 failed with stage
in 0 seconds
This diff is collapsed.
...@@ -2,65 +2,62 @@ ...@@ -2,65 +2,62 @@
"type": "object", "type": "object",
"$schema": "https://json-schema.org/draft/2020-12/schema#", "$schema": "https://json-schema.org/draft/2020-12/schema#",
"description": "Parameters to instantiate resilient KVM", "description": "Parameters to instantiate resilient KVM",
"unevaluatedProperties": false,
"allOf": [ "allOf": [
{ {
"$ref": "./instance-kvm-input-schema.json#", "$ref": "./instance-kvm-input-schema.json#/$defs/instance-parameters"
"additionalProperties": true }
],
"properties": {
"resilient-clone-number": {
"title": "Amount of backup(s) to create",
"description": "Amount of backup(s) to create. Each backup consists of a Pull Backup Server and a clone.",
"type": "integer",
"default": 1,
"optional": true
}, },
{ "-sla-0-computer_guid": {
"additionalProperties": true, "title": "Target computer for main instance",
"properties": { "description": "Target computer GUID for main instance.",
"resilient-clone-number": { "type": "string",
"title": "Amount of backup(s) to create", "optional": true
"description": "Amount of backup(s) to create. Each backup consists of a Pull Backup Server and a clone.", },
"type": "integer", "-sla-1-computer_guid": {
"default": 1, "title": "Target computer for first clone",
"optional": true "description": "Target computer for first clone and PBS.",
}, "type": "string",
"-sla-0-computer_guid": { "optional": true
"title": "Target computer for main instance", },
"description": "Target computer GUID for main instance.", "-sla-pbs1-computer_guid": {
"type": "string", "title": "Target computer for first PBS",
"optional": true "description": "Target computer for first PBS instance.",
}, "type": "string",
"-sla-1-computer_guid": { "optional": true
"title": "Target computer for first clone", },
"description": "Target computer for first clone and PBS.", "-sla-2-computer_guid": {
"type": "string", "title": "Target computer for second clone",
"optional": true "description": "Target computer for second clone and PBS.",
}, "type": "string",
"-sla-pbs1-computer_guid": { "optional": true
"title": "Target computer for first PBS", },
"description": "Target computer for first PBS instance.", "-sla-pbs2-computer_guid": {
"type": "string", "title": "Target computer for second PBS",
"optional": true "description": "Target computer for second PBS instance.",
}, "type": "string",
"-sla-2-computer_guid": { "optional": true
"title": "Target computer for second clone", },
"description": "Target computer for second clone and PBS.", "resiliency-backup-periodicity": {
"type": "string", "title": "Periodicity of backup",
"optional": true "description": "Periodicity of backup, in cron format.",
}, "type": "string",
"-sla-pbs2-computer_guid": { "optional": true
"title": "Target computer for second PBS", },
"description": "Target computer for second PBS instance.", "remove-backup-older-than": {
"type": "string", "title": "Remove backups older than...",
"optional": true "description": "Remove all the backups in PBS that are older than specified value. It should be rdiff-backup-compatible.",
}, "type": "string",
"resiliency-backup-periodicity": { "default": "2W",
"title": "Periodicity of backup", "optional": true
"description": "Periodicity of backup, in cron format.",
"type": "string",
"optional": true
},
"remove-backup-older-than": {
"title": "Remove backups older than...",
"description": "Remove all the backups in PBS that are older than specified value. It should be rdiff-backup-compatible.",
"type": "string",
"default": "2W",
"optional": true
}
}
} }
] }
} }
{ {
"$schema": "http://json-schema.org/draft-06/schema#", "$schema": "https://json-schema.org/draft/2019-09/schema",
"type": "object",
"description": "Parameters to instantiate Theia", "description": "Parameters to instantiate Theia",
"additionalProperties": false, "$defs": {
"properties": { "instance-parameters": {
"autorun": { "type": "object",
"title": "Automatically Run Software/Instance", "properties": {
"description": "The option used to pilot automatic build and run of software and instances hosted inside Theia. When 'running', build and run is done automatically in the background. When 'stopped' build and run processes are stopped and need to be run manually. When 'user-controlled', the user can manage it directly in the local supervisord. ", "autorun": {
"type": "string", "title": "Automatically Run Software/Instance",
"enum": [ "description": "The option used to pilot automatic build and run of software and instances hosted inside Theia. When 'running', build and run is done automatically in the background. When 'stopped' build and run processes are stopped and need to be run manually. When 'user-controlled', the user can manage it directly in the local supervisord. ",
"running", "type": "string",
"stopped", "enum": [
"user-controlled" "running",
], "stopped",
"default": "running" "user-controlled"
}, ],
"initial-embedded-instance": { "default": "running"
"title": "Initial Embedded Instance Configuration", },
"description": "One-shot optional JSON preconfiguration for an embedded instance. Only applied once when Theia is instantiated. Changing this option afterward will have no effect.", "initial-embedded-instance": {
"type": "string", "title": "Initial Embedded Instance Configuration",
"textarea": true, "description": "One-shot optional JSON preconfiguration for an embedded instance. Only applied once when Theia is instantiated. Changing this option afterward will have no effect.",
"examples": [ "type": "string",
"{\"software-url\": \"~/srv/project/slapos/software/html5as-base/software.cfg\"}", "textarea": true,
"{\"software-url\": \"~/srv/project/slapos/software/html5as/software.cfg\", \"software-type\": \"replicate\", \"instance-parameters\": {\"replicate-quantity\": 3}}" "examples": [
] "{\"software-url\": \"~/srv/project/slapos/software/html5as-base/software.cfg\"}",
}, "{\"software-url\": \"~/srv/project/slapos/software/html5as/software.cfg\", \"software-type\": \"replicate\", \"instance-parameters\": {\"replicate-quantity\": 3}}"
"forward-slapos-frontend-requests": { ]
"title": "Forward Frontend Requests in the Embedded SlapOS", },
"description": "Embedded SlapOS instance by default forwards frontend requests as shared instances attached to the Theia instance, so that HTTP frontends can be allocated for services. This behavior can be disabled, in that case frontends will not be allocated.", "forward-slapos-frontend-requests": {
"type": "string", "title": "Forward Frontend Requests in the Embedded SlapOS",
"enum": [ "description": "Embedded SlapOS instance by default forwards frontend requests as shared instances attached to the Theia instance, so that HTTP frontends can be allocated for services. This behavior can be disabled, in that case frontends will not be allocated.",
"enabled", "type": "string",
"disabled" "enum": [
], "enabled",
"default": "enabled" "disabled"
}, ],
"frontend-guid": { "default": "enabled"
"title": "Frontend Instance ID", },
"description": "Unique identifier of the frontend instance, like \"SOFTINST-11031\".", "frontend-guid": {
"type": "string" "title": "Frontend Instance ID",
}, "description": "Unique identifier of the frontend instance, like \"SOFTINST-11031\".",
"frontend-sr": { "type": "string"
"title": "Frontend Software URL", },
"description": "Software Release URL of the frontend instance, like \"http://example.com/path/to/software.cfg\".", "frontend-sr": {
"type": "string", "title": "Frontend Software URL",
"format": "uri", "description": "Software Release URL of the frontend instance, like \"http://example.com/path/to/software.cfg\".",
"default": "http://git.erp5.org/gitweb/slapos.git/blob_plain/HEAD:/software/apache-frontend/software.cfg" "type": "string",
}, "format": "uri",
"frontend-sr-type": { "default": "http://git.erp5.org/gitweb/slapos.git/blob_plain/HEAD:/software/apache-frontend/software.cfg"
"title": "Frontend Software Type", },
"description": "Type of the frontend instance, like \"frontend\".", "frontend-sr-type": {
"type": "string", "title": "Frontend Software Type",
"default": "RootSoftwareInstance" "description": "Type of the frontend instance, like \"frontend\".",
}, "type": "string",
"additional-frontend-guid": { "default": "RootSoftwareInstance"
"title": "Additional Frontend Instance ID", },
"description": "Unique identifier of the additional frontend instance, like \"SOFTINST-11031\", if empty won't be requested.", "additional-frontend-guid": {
"type": "string" "title": "Additional Frontend Instance ID",
}, "description": "Unique identifier of the additional frontend instance, like \"SOFTINST-11031\", if empty won't be requested.",
"additional-frontend-sr": { "type": "string"
"title": "Additional Frontend Software URL", },
"description": "Software Release URL of the frontend instance, like \"http://example.com/path/to/software.cfg\".", "additional-frontend-sr": {
"type": "string", "title": "Additional Frontend Software URL",
"format": "uri", "description": "Software Release URL of the frontend instance, like \"http://example.com/path/to/software.cfg\".",
"default": "http://git.erp5.org/gitweb/slapos.git/blob_plain/HEAD:/software/apache-frontend/software.cfg" "type": "string",
}, "format": "uri",
"additional-frontend-sr-type": { "default": "http://git.erp5.org/gitweb/slapos.git/blob_plain/HEAD:/software/apache-frontend/software.cfg"
"title": "Additional Frontend Software Type", },
"description": "Type of the frontend instance, like \"frontend\".", "additional-frontend-sr-type": {
"type": "string", "title": "Additional Frontend Software Type",
"default": "RootSoftwareInstance" "description": "Type of the frontend instance, like \"frontend\".",
"type": "string",
"default": "RootSoftwareInstance"
}
}
} }
} },
"unevaluatedProperties": false,
"allOf": [
{
"$ref": "#/$defs/instance-parameters"
}
]
} }
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema#", "$schema": "https://json-schema.org/draft/2019-09/schema",
"type": "object", "type": "object",
"description": "Parameters to instantiate resilient Theia", "description": "Parameters to instantiate resilient Theia",
"unevaluatedProperties": false,
"allOf": [ "allOf": [
{ {
"$ref": "./instance-input-schema.json#", "$ref": "./instance-input-schema.json#/$defs/instance-parameters"
"additionalProperties": true }
],
"properties": {
"resilient-clone-number": {
"title": "Amount of backup(s) to create",
"description": "Amount of backup(s) to create. Each backup consists of a Pull Backup Server and a clone.",
"type": "integer",
"default": 1,
"minimum": 0,
"maximum": 2,
"optional": true
}, },
{ "-sla-theia0-computer_guid": {
"additionalProperties": true, "title": "Target computer for main instance",
"properties": { "description": "Target computer GUID for main instance.",
"resilient-clone-number": { "type": "string",
"title": "Amount of backup(s) to create", "optional": true
"description": "Amount of backup(s) to create. Each backup consists of a Pull Backup Server and a clone.", },
"type": "integer", "-sla-theia1-computer_guid": {
"default": 1, "title": "Target computer for first clone",
"minimum": 0, "description": "Target computer for first clone instance.",
"maximum": 2, "type": "string",
"optional": true "optional": true
}, },
"-sla-theia0-computer_guid": { "-sla-pbs1-computer_guid": {
"title": "Target computer for main instance", "title": "Target computer for first PBS",
"description": "Target computer GUID for main instance.", "description": "Target computer for first PBS instance.",
"type": "string", "type": "string",
"optional": true "optional": true
}, },
"-sla-theia1-computer_guid": { "-sla-theia2-computer_guid": {
"title": "Target computer for first clone", "title": "Target computer for second clone",
"description": "Target computer for first clone instance.", "description": "Target computer for second clone instance.",
"type": "string", "type": "string",
"optional": true "optional": true
}, },
"-sla-pbs1-computer_guid": { "-sla-pbs2-computer_guid": {
"title": "Target computer for first PBS", "title": "Target computer for second PBS",
"description": "Target computer for first PBS instance.", "description": "Target computer for second PBS instance.",
"type": "string", "type": "string",
"optional": true "optional": true
}, },
"-sla-theia2-computer_guid": { "resiliency-backup-periodicity": {
"title": "Target computer for second clone", "title": "Periodicity of backup",
"description": "Target computer for second clone instance.", "description": "Periodicity of backup, in cron format.",
"type": "string", "type": "string",
"optional": true "optional": true
}, },
"-sla-pbs2-computer_guid": { "remove-backup-older-than": {
"title": "Target computer for second PBS", "title": "Remove backups older than...",
"description": "Target computer for second PBS instance.", "description": "Remove all the backups in PBS that are older than specified value. It should be rdiff-backup-compatible.",
"type": "string", "type": "string",
"optional": true "default": "2W",
}, "optional": true
"resiliency-backup-periodicity": {
"title": "Periodicity of backup",
"description": "Periodicity of backup, in cron format.",
"type": "string",
"optional": true
},
"remove-backup-older-than": {
"title": "Remove backups older than...",
"description": "Remove all the backups in PBS that are older than specified value. It should be rdiff-backup-compatible.",
"type": "string",
"default": "2W",
"optional": true
}
}
} }
] }
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment