Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSON schema: improve non-storage parts #1437

Merged
merged 6 commits into from
Jul 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"]
mvidner marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
},
"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 All @@ -117,7 +129,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 @@ -139,7 +160,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 @@ -156,6 +186,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 @@ -188,29 +219,30 @@
}
}
}
},
"required": [
"id"
]
}
}
}
}
},
"user": {
"title": "First user settings",
"type": "object",
"additionalProperties": false,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

feature request: I am surprised that we don't allow hashed passwords in the profile

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you are right, that's something we need to implement. I have created a placeholder card in Trello.

"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 @@ -222,6 +254,7 @@
"root": {
"title": "Root authentication settings",
"type": "object",
"additionalProperties": false,
"properties": {
"password": {
"title": "Root password",
Expand All @@ -238,16 +271,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 @@ -274,8 +309,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 @@ -289,8 +325,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 @@ -308,9 +345,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 @@ -367,8 +405,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 @@ -380,8 +419,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 @@ -478,7 +518,8 @@
"$ref": "#/$defs/sizeValue"
},
"minItems": 1,
"maxItems": 2
"maxItems": 2,
"examples": [[1024, "2 GiB"]]
},
{
"title": "Size range",
Expand Down Expand Up @@ -513,9 +554,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 @@ -526,8 +568,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 @@ -539,8 +582,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 @@ -552,8 +596,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 @@ -576,7 +621,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"]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW, here the examples feature really shines because it provides an alternative to the dense regexp

Unfortunately, agama profile validate does not check whether the schema is internally consistent and uses only valid examples. Like, I could use a number here and it would not notice.

},
"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