Skip to content

Commit

Permalink
feat(schema): add schema for storage config model
Browse files Browse the repository at this point in the history
  • Loading branch information
joseivanlopez committed Nov 14, 2024
1 parent 8e83ea1 commit 2c8e82f
Show file tree
Hide file tree
Showing 2 changed files with 164 additions and 0 deletions.
69 changes: 69 additions & 0 deletions rust/agama-lib/share/examples/storage/model.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{
"drives": [
{
"name": "/dev/vda",
"alias": "root",
"mountPath": "/",
"filesystem": {
"default": true,
"type": "btrfs",
"snapshots": true
},
"spacePolicy": "delete"
},
{
"name": "/dev/vdb",
"spacePolicy": "custom",
"ptableType": "gpt",
"partitions": [
{
"name": "/dev/vda1",
"size": {
"default": false,
"min": 0,
"max": 1234567
},
"deleteIfNeeded": true,
"resizeIfNeeded": true
},
{
"name": "/dev/vda2",
"size": {
"default": false,
"min": 1234567,
"max": 1234567
},
"resize": true
},
{
"name": "/dev/vdb3",
"delete": true
},
{
"size": {
"default": true,
"min": 4444,
"max": 8888
},
"mountPath": "swap",
"filesystem": {
"default": true,
"type": "xfs"
}
},
{
"size": {
"default": false,
"min": 100000,
"max": 100000
},
"mountPath": "/home",
"filesystem": {
"default": false,
"type": "xfs"
}
}
]
}
]
}
95 changes: 95 additions & 0 deletions rust/agama-lib/share/storage.model.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
{
"title": "Config model",
"type": "object",
"additionalProperties": false,
"properties": {
"drives": {
"type": "array",
"items": { "$ref": "#/$defs/drive" }
}
},
"$defs": {
"drive": {
"type": "object",
"additionalProperties": false,
"required": ["name"],
"properties": {
"name": { "type": "string" },
"alias": { "type": "string" },
"mountPath": { "type": "string" },
"filesystem": { "$ref": "#/$defs/filesystem" },
"spacePolicy": { "$ref": "#/$defs/spacePolicy" },
"ptableType": { "$ref": "#/$defs/ptableType" },
"partitions": {
"type": "array",
"items": { "$ref": "#/$defs/partition" }
}
}
},
"partition": {
"type": "object",
"additionalProperties": false,
"properties": {
"name": { "type": "string" },
"alias": { "type": "string" },
"id": { "$ref": "#/$defs/partitionId" },
"mountPath": { "type": "string" },
"filesystem": { "$ref": "#/$defs/filesystem" },
"size": { "$ref": "#/$defs/size" },
"delete": { "type": "boolean" },
"deleteIfNeeded": { "type": "boolean" },
"resize": { "type": "boolean" },
"resizeIfNeeded": { "type": "boolean" }
}
},
"spacePolicy": {
"enum": ["delete", "resize", "keep", "custom"]
},
"ptableType": {
"enum": ["gpt", "msdos", "dasd"]
},
"partitionId": {
"enum": ["linux", "swap", "lvm", "raid", "esp", "prep", "bios_boot"]
},
"filesystem": {
"type": "object",
"additionalProperties": false,
"required": ["default"],
"properties": {
"default": { "type": "boolean" },
"type": { "$ref": "#/$defs/filesystemType" },
"snapshots": { "type": "boolean" }
}
},
"filesystemType": {
"enum": [
"bcachefs",
"btrfs",
"exfat",
"ext2",
"ext3",
"ext4",
"f2fs",
"jfs",
"nfs",
"nilfs2",
"ntfs",
"reiserfs",
"swap",
"tmpfs",
"vfat",
"xfs"
]
},
"size": {
"type": "object",
"additionalProperties": false,
"required": ["default", "min"],
"properties": {
"default": { "type": "boolean" },
"min": { "type": "integer", "minimum": 0 },
"max": { "type": "integer", "minimum": 0 }
}
}
}
}

0 comments on commit 2c8e82f

Please sign in to comment.