Skip to content

Commit

Permalink
JSON schema: improve non-storage parts, specify examples (#1437)
Browse files Browse the repository at this point in the history
## Problem

While reviewing #1263 I read the whole schema and saw room for
improvement. Small things

## Solution

- disallow additional properties
- more specific type than string
- put examples to their dedicated property

## Testing

Minimal, just making sure the schema itself is valid, by

```console
$ agama profile validate rust/agama-lib/share/examples/profile_gnome.json
The profile is valid
```
  • Loading branch information
mvidner authored Jul 19, 2024
2 parents 1b1044a + d3cc748 commit 6321fe0
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 48 deletions.
132 changes: 89 additions & 43 deletions rust/agama-lib/share/profile.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,23 @@
"properties": {
"patterns": {
"title": "List of patterns to install",
"type": "array"
"type": "array",
"items": {
"type": "string",
"examples": ["minimal_base"]
}
}
}
},
"product": {
"title": "Product to install",
"type": "object",
"additionalProperties": false,
"required": ["id"],
"properties": {
"id": {
"title": "Product identifier",
"description": "The id field from a products.d/foo.yaml file",
"type": "string"
},
"registrationCode": {
Expand All @@ -46,6 +53,9 @@
"items": {
"type": "object",
"additionalProperties": false,
"required": [
"id"
],
"properties": {
"id": {
"title": "Connection ID",
Expand All @@ -66,7 +76,7 @@
"minimum": 0
},
"method4": {
"title": "IPv4 configuration method (e.g., 'auto')",
"title": "IPv4 configuration method",
"type": "string",
"enum": [
"auto",
Expand All @@ -76,7 +86,7 @@
]
},
"method6": {
"title": "IPv6 configuration method (e.g., 'auto')",
"title": "IPv6 configuration method",
"type": "string",
"enum": [
"auto",
Expand All @@ -86,12 +96,14 @@
]
},
"gateway4": {
"title": "Connection gateway address (e.g., '192.168.122.1')",
"type": "string"
"title": "Connection gateway address",
"type": "string",
"examples": ["192.168.122.1"]
},
"gateway6": {
"title": "Connection gateway address (e.g., '::ffff:c0a8:7a01')",
"type": "string"
"title": "Connection gateway address",
"type": "string",
"examples": ["::ffff:c0a8:7a01"]
},
"addresses": {
"type": "array",
Expand Down Expand Up @@ -129,7 +141,16 @@
"type": "string"
},
"security": {
"type": "string"
"type": "string",
"enum": [
"none",
"owe",
"ieee8021x",
"wpa-psk",
"sae",
"wpa-eap",
"wpa-eap-suite-b192"
]
},
"ssid": {
"type": "string"
Expand All @@ -151,7 +172,16 @@
"additionalProperties": false,
"properties": {
"mode": {
"type": "string"
"type": "string",
"enum": [
"balance-rr",
"active-backup",
"balance-xor",
"broadcast",
"802.3ad",
"balance-tlb",
"balance-alb"
]
},
"options": {
"type": "string"
Expand All @@ -168,6 +198,7 @@
"match": {
"type": "object",
"title": "Match settings",
"description": "Identifies the network interface to apply the connection settings to",
"additionalProperties": false,
"properties": {
"kernel": {
Expand Down Expand Up @@ -200,29 +231,30 @@
}
}
}
},
"required": [
"id"
]
}
}
}
}
},
"user": {
"title": "First user settings",
"type": "object",
"additionalProperties": false,
"properties": {
"fullName": {
"title": "Full name (e.g., 'Jane Doe')",
"type": "string"
"title": "Full name",
"type": "string",
"examples": ["Jane Doe"]
},
"userName": {
"title": "User login name (e.g., 'jane.doe')",
"type": "string"
"title": "User login name",
"type": "string",
"examples": ["jane.doe"]
},
"password": {
"title": "User password (e.g., 'nots3cr3t')",
"type": "string"
"title": "User password",
"type": "string",
"examples": ["nots3cr3t"]
}
},
"required": [
Expand All @@ -234,6 +266,7 @@
"root": {
"title": "Root authentication settings",
"type": "object",
"additionalProperties": false,
"properties": {
"password": {
"title": "Root password",
Expand All @@ -250,16 +283,18 @@
"type": "object",
"properties": {
"language": {
"title": "System language ID (e.g., 'en_US')",
"type": "string"
"title": "System language ID",
"type": "string",
"examples": ["en_US.UTF-8", "en_US"]
},
"keyboard": {
"title": "Keyboard layout ID",
"type": "string"
},
"timezone": {
"title": "Time zone identifier such as 'Europe/Berlin'",
"type": "string"
"type": "string",
"examples": ["Europe/Berlin"]
}
}
},
Expand All @@ -286,8 +321,9 @@
"required": ["disk"],
"properties": {
"disk": {
"title": "Disk device name (e.g., '/dev/vda')",
"type": "string"
"title": "Disk device name",
"type": "string",
"examples": ["/dev/vda"]
}
}
},
Expand All @@ -301,8 +337,9 @@
"title": "Devices in which to create the physical volumes",
"type": "array",
"items": {
"title": "Disk device name (e.g., '/dev/vda')",
"type": "string"
"title": "Disk device name",
"type": "string",
"examples": ["/dev/vda"]
}
}
}
Expand All @@ -320,9 +357,10 @@
"type": "boolean"
},
"device": {
"title": "Device to use for booting (e.g., '/dev/vda')",
"title": "Device to use for booting",
"description": "The installation device is used by default for booting",
"type": "string"
"type": "string",
"examples": ["/dev/vda"]
}
}
},
Expand Down Expand Up @@ -379,8 +417,9 @@
"additionalProperties": false,
"properties": {
"forceDelete": {
"title": "Device to delete (e.g., '/dev/vda')",
"type": "string"
"title": "Device to delete",
"type": "string",
"examples": ["/dev/vda"]
}
}
},
Expand All @@ -392,8 +431,9 @@
"additionalProperties": false,
"properties": {
"resize": {
"title": "Device to allow resizing (e.g., '/dev/vda')",
"type": "string"
"title": "Device to allow resizing",
"type": "string",
"examples": ["/dev/vda"]
}
}
}
Expand Down Expand Up @@ -490,7 +530,8 @@
"$ref": "#/$defs/sizeValue"
},
"minItems": 1,
"maxItems": 2
"maxItems": 2,
"examples": [[1024, "2 GiB"]]
},
{
"title": "Size range",
Expand Down Expand Up @@ -525,9 +566,10 @@
"additionalProperties": false,
"properties": {
"newPartition": {
"title": "Name of a disk device (e.g., '/dev/vda')",
"type": "string"
}
"title": "Name of a disk device",
"type": "string",
"examples": ["/dev/vda"]
}
}
},
{
Expand All @@ -538,8 +580,9 @@
"required": ["newVg"],
"properties": {
"newVg": {
"title": "Name of a disk device (e.g., '/dev/vda')",
"type": "string"
"title": "Name of a disk device",
"type": "string",
"examples": ["/dev/vda"]
}
}
},
Expand All @@ -551,8 +594,9 @@
"required": ["device"],
"properties": {
"device": {
"title": "Name of a device (e.g., '/dev/vda1')",
"type": "string"
"title": "Name of a device",
"type": "string",
"examples": ["/dev/vda1"]
}
}
},
Expand All @@ -564,8 +608,9 @@
"required": ["filesystem"],
"properties": {
"filesystem": {
"title": "Name of a device containing the file system (e.g., '/dev/vda1')",
"type": "string"
"title": "Name of a device containing the file system",
"type": "string",
"examples": ["/dev/vda1"]
}
}
}
Expand All @@ -588,7 +633,8 @@
"sizeString": {
"title": "Human readable size (e.g., '2 GiB')",
"type": "string",
"pattern": "^[0-9]+(\\.[0-9]+)?(\\s*([KkMmGgTtPpEeZzYy][iI]?)?[Bb])?$"
"pattern": "^[0-9]+(\\.[0-9]+)?(\\s*([KkMmGgTtPpEeZzYy][iI]?)?[Bb])?$",
"examples": ["2 GiB", "1.5 TB", "1TIB", "1073741824 b", "1073741824"]
},
"sizeInteger": {
"title": "Size in bytes",
Expand Down
5 changes: 1 addition & 4 deletions setup-web.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@ $SUDO zypper --non-interactive install \

cd web

if [ ! -e node_modules ]; then
npm install
fi

npm install
npm run build

cd -
Expand Down
2 changes: 1 addition & 1 deletion testing_using_container.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ set -x
set -eu

# https://build.opensuse.org/package/show/systemsmanagement:Agama:Devel/agama-testing
CIMAGE=registry.opensuse.org/systemsmanagement/agama/staging/containers/opensuse/agama-testing:latest
CIMAGE=registry.opensuse.org/systemsmanagement/agama/devel/containers/opensuse/agama-testing:latest
# rename this if you test multiple things
CNAME=agama

Expand Down

0 comments on commit 6321fe0

Please sign in to comment.