From f8c7bc4fb4e0dc243ac8896f54fc8bfff0f7e652 Mon Sep 17 00:00:00 2001 From: Stefan Sterz Date: Fri, 4 Mar 2022 12:31:57 +0100 Subject: [PATCH] fix #3067: api: add support for multi-line comments in node.cfg add support for multi-line comments to node.cfg and the api, similar to how pve handles multi-line comments Signed-off-by: Stefan Sterz Acked-by: Wolfgang Bumiller --- pbs-api-types/src/lib.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pbs-api-types/src/lib.rs b/pbs-api-types/src/lib.rs index 2f51afd9..421566f7 100644 --- a/pbs-api-types/src/lib.rs +++ b/pbs-api-types/src/lib.rs @@ -137,6 +137,8 @@ const_regex! { pub SINGLE_LINE_COMMENT_REGEX = r"^[[:^cntrl:]]*$"; + pub MULTI_LINE_COMMENT_REGEX = r"(?m)^([[:^cntrl:]]*)$"; + pub BACKUP_REPO_URL_REGEX = concat!( r"^^(?:(?:(", USER_ID_REGEX_STR!(), "|", APITOKEN_ID_REGEX_STR!(), @@ -273,6 +275,13 @@ pub const SINGLE_LINE_COMMENT_SCHEMA: Schema = StringSchema::new("Comment (singl .format(&SINGLE_LINE_COMMENT_FORMAT) .schema(); +pub const MULTI_LINE_COMMENT_FORMAT: ApiStringFormat = + ApiStringFormat::Pattern(&MULTI_LINE_COMMENT_REGEX); + +pub const MULTI_LINE_COMMENT_SCHEMA: Schema = StringSchema::new("Comment (multiple lines).") + .format(&MULTI_LINE_COMMENT_FORMAT) + .schema(); + pub const SUBSCRIPTION_KEY_SCHEMA: Schema = StringSchema::new("Proxmox Backup Server subscription key.") .format(&SUBSCRIPTION_KEY_FORMAT) .min_length(15)