api: add ZPOOL_NAME_SCHEMA and regex

poolnames can containe spaces and some other special characters

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
Dominik Csapak
2020-07-08 14:59:15 +02:00
committed by Dietmar Maurer
parent 20a4e4e252
commit 7957fabff2
2 changed files with 6 additions and 1 deletions

View File

@ -41,6 +41,9 @@ pub const ZFS_ASHIFT_SCHEMA: Schema = IntegerSchema::new(
.default(12)
.schema();
pub const ZPOOL_NAME_SCHEMA: Schema =StringSchema::new("ZFS Pool Name")
.format(&ApiStringFormat::Pattern(&ZPOOL_NAME_REGEX))
.schema();
#[api(
default: "On",
@ -157,7 +160,7 @@ pub fn list_zpools() -> Result<Vec<ZpoolListItem>, Error> {
schema: NODE_SCHEMA,
},
name: {
schema: DATASTORE_SCHEMA,
schema: ZPOOL_NAME_SCHEMA,
},
},
},