all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: "Fabian Grünbichler" <f.gruenbichler@proxmox.com>
To: pdm-devel@lists.proxmox.com
Subject: [pdm-devel] [PATCH datacenter-manager 1/3] remote config: let save_config take ownership
Date: Mon,  1 Dec 2025 10:29:13 +0100	[thread overview]
Message-ID: <20251201092941.291325-2-f.gruenbichler@proxmox.com> (raw)
In-Reply-To: <20251201092941.291325-1-f.gruenbichler@proxmox.com>

as preparation for automatically modifying the saved config to split out token
secrets, if needed.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
---
 lib/pdm-config/src/remotes.rs | 9 +++++----
 server/src/api/remotes.rs     | 6 +++---
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/lib/pdm-config/src/remotes.rs b/lib/pdm-config/src/remotes.rs
index 74c4671..fc78707 100644
--- a/lib/pdm-config/src/remotes.rs
+++ b/lib/pdm-config/src/remotes.rs
@@ -47,7 +47,7 @@ pub fn config() -> Result<(SectionConfigData<Remote>, ConfigDigest), Error> {
 /// Replace the currently persisted remotes config
 ///
 /// Will panic if the the remote config instance has not been set before.
-pub fn save_config(config: &SectionConfigData<Remote>) -> Result<(), Error> {
+pub fn save_config(config: SectionConfigData<Remote>) -> Result<(), Error> {
     instance().save_config(config)
 }
 
@@ -57,7 +57,7 @@ pub trait RemoteConfig {
     /// Lock the remotes config
     fn lock_config(&self) -> Result<ApiLockGuard, Error>;
     /// Replace the currently persisted remotes config
-    fn save_config(&self, remotes: &SectionConfigData<Remote>) -> Result<(), Error>;
+    fn save_config(&self, remotes: SectionConfigData<Remote>) -> Result<(), Error>;
 }
 
 /// Default, production implementation for reading/writing the `remotes.cfg`
@@ -75,11 +75,12 @@ impl RemoteConfig for DefaultRemoteConfig {
 
         let digest = openssl::sha::sha256(content.as_bytes());
         let data = Remote::parse_section_config(REMOTES_CFG_FILENAME, &content)?;
+
         Ok((data, digest.into()))
     }
 
-    fn save_config(&self, config: &SectionConfigData<Remote>) -> Result<(), Error> {
-        let raw = Remote::write_section_config(REMOTES_CFG_FILENAME, config)?;
+    fn save_config(&self, config: SectionConfigData<Remote>) -> Result<(), Error> {
+        let raw = Remote::write_section_config(REMOTES_CFG_FILENAME, &config)?;
         replace_config(REMOTES_CFG_FILENAME, raw.as_bytes())
     }
 }
diff --git a/server/src/api/remotes.rs b/server/src/api/remotes.rs
index 76b005d..a7463b9 100644
--- a/server/src/api/remotes.rs
+++ b/server/src/api/remotes.rs
@@ -184,7 +184,7 @@ pub async fn add_remote(mut entry: Remote, create_token: Option<String>) -> Resu
     let name = entry.id.clone();
     remotes.insert(entry.id.to_owned(), entry);
 
-    pdm_config::remotes::save_config(&remotes)?;
+    pdm_config::remotes::save_config(remotes)?;
 
     if let Err(e) = metric_collection::trigger_metric_collection(Some(name), false).await {
         log::error!("could not trigger metric collection after adding remote: {e}");
@@ -268,7 +268,7 @@ pub fn update_remote(
         entry.web_url = updater.web_url;
     }
 
-    pdm_config::remotes::save_config(&remotes)?;
+    pdm_config::remotes::save_config(remotes)?;
 
     Ok(())
 }
@@ -291,7 +291,7 @@ pub fn remove_remote(id: String) -> Result<(), Error> {
         http_bail!(NOT_FOUND, "no such entry {id:?}");
     }
 
-    pdm_config::remotes::save_config(&remotes)?;
+    pdm_config::remotes::save_config(remotes)?;
 
     Ok(())
 }
-- 
2.47.3



_______________________________________________
pdm-devel mailing list
pdm-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel

  reply	other threads:[~2025-12-01  9:29 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-01  9:29 [pdm-devel] [PATCH datacenter-manager 0/3] token secret shadow config Fabian Grünbichler
2025-12-01  9:29 ` Fabian Grünbichler [this message]
2025-12-01  9:29 ` [pdm-devel] [PATCH datacenter-manager 2/3] remote config: get token secret from shadow file if shadowed Fabian Grünbichler
2025-12-01  9:29 ` [pdm-devel] [PATCH datacenter-manager 3/3] remote config: shadow token secrets when saving Fabian Grünbichler
2025-12-01 14:39   ` Lukas Wagner
2025-12-01 14:46 ` [pdm-devel] [PATCH datacenter-manager 0/3] token secret shadow config Lukas Wagner
2025-12-01 16:44 ` [pdm-devel] applied: " Thomas Lamprecht

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251201092941.291325-2-f.gruenbichler@proxmox.com \
    --to=f.gruenbichler@proxmox.com \
    --cc=pdm-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal