stages/shell.init: add top-level files property

Add a top level property "files" to the schema and move the rest of the
existing schema one level down.  This way we can support adding global
properties in the future if we ever need to expand the scope of the
stage.
This commit is contained in:
Achilleas Koutsou 2023-02-15 12:01:40 +01:00
parent eb903a9596
commit d3229dc929
3 changed files with 70 additions and 58 deletions

View file

@ -12,26 +12,33 @@ import osbuild.api
SCHEMA_2 = r"""
"options": {
"additionalProperties": false,
"properties": {
"patternProperties": {
"^[a-zA-Z0-9\\.\\-_]{1,250}$": {
"type": "object",
"additionalProperties": false,
"properties": {
"env": {
"type": "array",
"description": "Environment variables to set and export on shell init.",
"minItems": 1,
"items": {
"type": "object",
"additionalProperties": false,
"required": ["key", "value"],
"properties": {
"key": {
"type": "string",
"pattern": "^[A-Z_][A-Z0-9_]*$"
},
"value": "string"
"files": {
"type": "object",
"additionalProperties": false,
"patternProperties": {
"^[a-zA-Z0-9\\.\\-_]{1,250}$": {
"type": "object",
"additionalProperties": false,
"properties": {
"env": {
"type": "array",
"description": "Environment variables to set and export on shell init.",
"minItems": 1,
"items": {
"type": "object",
"additionalProperties": false,
"required": ["key", "value"],
"properties": {
"key": {
"type": "string",
"pattern": "^[A-Z_][A-Z0-9_]*$"
},
"value": {
"type": "string"
}
}
}
}
}
@ -44,7 +51,8 @@ SCHEMA_2 = r"""
def main(tree, options):
for filename, opts in options.items():
files = options.get("files", {})
for filename, opts in files.items():
lines = []
for item in opts["env"]:
key = item["key"]

View file

@ -394,25 +394,27 @@
{
"type": "org.osbuild.shell.init",
"options": {
"test_env": {
"env": [
{
"key": "VAR",
"value": "val"
}
]
},
"test_env.2": {
"env": [
{
"key": "ONE",
"value": "1"
},
{
"key": "TWO",
"value": "2"
}
]
"files": {
"test_env": {
"env": [
{
"key": "VAR",
"value": "val"
}
]
},
"test_env.2": {
"env": [
{
"key": "ONE",
"value": "1"
},
{
"key": "TWO",
"value": "2"
}
]
}
}
}
}

View file

@ -51,25 +51,27 @@
{
"type": "org.osbuild.shell.init",
"options": {
"test_env": {
"env": [
{
"key": "VAR",
"value": "val"
}
]
},
"test_env.2": {
"env": [
{
"key": "ONE",
"value": "1"
},
{
"key": "TWO",
"value": "2"
}
]
"files": {
"test_env": {
"env": [
{
"key": "VAR",
"value": "val"
}
]
},
"test_env.2": {
"env": [
{
"key": "ONE",
"value": "1"
},
{
"key": "TWO",
"value": "2"
}
]
}
}
}
}