[pbs-devel] applied: [PATCH proxmox-backup v3 2/7] api2/types: add TAPE_RESTORE_SNAPSHOT_SCHEMA
Dietmar Maurer
dietmar at proxmox.com
Fri May 7 12:51:08 CEST 2021
applied with a cleanup on top:
I moved all api related type/regx definition from backup_info.rs to
src/api2/types/mod.rs
On 5/6/21 2:20 PM, Dominik Csapak wrote:
> which is 'store:type/id/time'
>
> needed to refactor SNAPSHOT_PATH_REGEX_STR from backup_info
>
> Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
> ---
> src/api2/types/mod.rs | 11 +++++++++++
> src/backup.rs | 1 +
> src/backup/backup_info.rs | 9 ++++++++-
> 3 files changed, 20 insertions(+), 1 deletion(-)
>
> diff --git a/src/api2/types/mod.rs b/src/api2/types/mod.rs
> index e829f207..21b5eade 100644
> --- a/src/api2/types/mod.rs
> +++ b/src/api2/types/mod.rs
> @@ -114,6 +114,8 @@ const_regex!{
> pub UUID_REGEX = r"^[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}$";
>
> pub DATASTORE_MAP_REGEX = concat!(r"(:?", PROXMOX_SAFE_ID_REGEX_STR!(), r"=)?", PROXMOX_SAFE_ID_REGEX_STR!());
> +
> + pub TAPE_RESTORE_SNAPSHOT_REGEX = concat!(r"^", PROXMOX_SAFE_ID_REGEX_STR!(), r":", SNAPSHOT_PATH_REGEX_STR!(), r"$");
> }
>
> pub const SYSTEMD_DATETIME_FORMAT: ApiStringFormat =
> @@ -185,6 +187,9 @@ pub const BLOCKDEVICE_NAME_FORMAT: ApiStringFormat =
> pub const DATASTORE_MAP_FORMAT: ApiStringFormat =
> ApiStringFormat::Pattern(&DATASTORE_MAP_REGEX);
>
> +pub const TAPE_RESTORE_SNAPSHOT_FORMAT: ApiStringFormat =
> + ApiStringFormat::Pattern(&TAPE_RESTORE_SNAPSHOT_REGEX);
> +
> pub const PASSWORD_SCHEMA: Schema = StringSchema::new("Password.")
> .format(&PASSWORD_FORMAT)
> .min_length(1)
> @@ -396,6 +401,12 @@ pub const DATASTORE_MAP_LIST_SCHEMA: Schema = StringSchema::new(
> .format(&ApiStringFormat::PropertyString(&DATASTORE_MAP_ARRAY_SCHEMA))
> .schema();
>
> +pub const TAPE_RESTORE_SNAPSHOT_SCHEMA: Schema = StringSchema::new(
> + "A snapshot in the format: 'store:type/id/time")
> + .format(&TAPE_RESTORE_SNAPSHOT_FORMAT)
> + .type_text("store:type/id/time")
> + .schema();
> +
> pub const MEDIA_SET_UUID_SCHEMA: Schema =
> StringSchema::new("MediaSet Uuid (We use the all-zero Uuid to reseve an empty media for a specific pool).")
> .format(&UUID_FORMAT)
> diff --git a/src/backup.rs b/src/backup.rs
> index cca43881..ae937be0 100644
> --- a/src/backup.rs
> +++ b/src/backup.rs
> @@ -238,6 +238,7 @@ pub use fixed_index::*;
> mod dynamic_index;
> pub use dynamic_index::*;
>
> +#[macro_use]
> mod backup_info;
> pub use backup_info::*;
>
> diff --git a/src/backup/backup_info.rs b/src/backup/backup_info.rs
> index b0f6e31c..f39f2ed4 100644
> --- a/src/backup/backup_info.rs
> +++ b/src/backup/backup_info.rs
> @@ -25,6 +25,13 @@ macro_rules! BACKUP_TIME_RE {
> };
> }
>
> +#[macro_export]
> +macro_rules! SNAPSHOT_PATH_REGEX_STR {
> + () => (
> + concat!(r"(", BACKUP_TYPE_RE!(), ")/(", BACKUP_ID_RE!(), ")/(", BACKUP_TIME_RE!(), r")")
> + );
> +}
> +
> const_regex! {
> BACKUP_FILE_REGEX = r"^.*\.([fd]idx|blob)$";
>
> @@ -37,7 +44,7 @@ const_regex! {
> GROUP_PATH_REGEX = concat!(r"^(", BACKUP_TYPE_RE!(), ")/(", BACKUP_ID_RE!(), r")$");
>
> SNAPSHOT_PATH_REGEX = concat!(
> - r"^(", BACKUP_TYPE_RE!(), ")/(", BACKUP_ID_RE!(), ")/(", BACKUP_TIME_RE!(), r")$");
> + r"^", SNAPSHOT_PATH_REGEX_STR!(), r"$");
> }
>
> /// BackupGroup is a directory containing a list of BackupDir
More information about the pbs-devel
mailing list