[pbs-devel] [PATCH proxmox-backup 1/4] config: sync: use same config section type `sync` for push and pull

Christian Ebner c.ebner at proxmox.com
Mon Nov 25 18:40:09 CET 2024


Use `sync` as config section type string for both, sync jobs in push
and pull direction, renaming the now combined config plugin to sync
plugin.

Commit bcd80bf9 ("api types/config: add `sync-push` config type for
push sync jobs") introduced the additional config type with the
intend to reduce possible misconfiguration. Partially revert this to
use the same config type string again, since the misconfiguration
can happen nevertheless (by editing the config type) and currently
sync job configs are only listed partially when fetched via the
config api endpoint. The filtering based on the additional api
parameter is however retained.

Signed-off-by: Christian Ebner <c.ebner at proxmox.com>
---
 pbs-config/src/sync.rs | 17 ++++-------------
 1 file changed, 4 insertions(+), 13 deletions(-)

diff --git a/pbs-config/src/sync.rs b/pbs-config/src/sync.rs
index 7fc977e77..10f528b5e 100644
--- a/pbs-config/src/sync.rs
+++ b/pbs-config/src/sync.rs
@@ -6,7 +6,7 @@ use anyhow::Error;
 use proxmox_schema::{ApiType, Schema};
 use proxmox_section_config::{SectionConfig, SectionConfigData, SectionConfigPlugin};
 
-use pbs_api_types::{SyncDirection, SyncJobConfig, JOB_ID_SCHEMA};
+use pbs_api_types::{SyncJobConfig, JOB_ID_SCHEMA};
 
 use crate::{open_backup_lockfile, replace_backup_config, BackupLockGuard};
 
@@ -18,19 +18,10 @@ fn init() -> SectionConfig {
         _ => unreachable!(),
     };
 
-    let pull_plugin = SectionConfigPlugin::new(
-        SyncDirection::Pull.as_config_type_str().to_string(),
-        Some(String::from("id")),
-        obj_schema,
-    );
-    let push_plugin = SectionConfigPlugin::new(
-        SyncDirection::Push.as_config_type_str().to_string(),
-        Some(String::from("id")),
-        obj_schema,
-    );
+    let sync_plugin =
+        SectionConfigPlugin::new("sync".to_string(), Some(String::from("id")), obj_schema);
     let mut config = SectionConfig::new(&JOB_ID_SCHEMA);
-    config.register_plugin(pull_plugin);
-    config.register_plugin(push_plugin);
+    config.register_plugin(sync_plugin);
 
     config
 }
-- 
2.39.5





More information about the pbs-devel mailing list