From: Lukas Wagner <l.wagner@proxmox.com>
To: pdm-devel@lists.proxmox.com
Subject: [PATCH datacenter-manager v3 06/21] pdm-config: remotes: rename trait methods to read/write/lock
Date: Thu, 27 Aug 2026 13:42:29 +0200 [thread overview]
Message-ID: <20260827114244.424784-7-l.wagner@proxmox.com> (raw)
In-Reply-To: <20260827114244.424784-1-l.wagner@proxmox.com>
This makes the use of these less awkward when being called via the trait
object itself, e.g. on a dependency injected application context object:
app.remote_config().read()
instead of
app.remote_config().config()
Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
---
lib/pdm-config/src/remotes.rs | 24 ++++++++++++------------
server/src/test_support/fake_remote.rs | 8 ++++----
2 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/lib/pdm-config/src/remotes.rs b/lib/pdm-config/src/remotes.rs
index a1004cfe..47754e9b 100644
--- a/lib/pdm-config/src/remotes.rs
+++ b/lib/pdm-config/src/remotes.rs
@@ -35,36 +35,36 @@ fn instance() -> &'static (dyn RemoteConfig + Send + Sync) {
///
/// Will panic if the the remote config instance has not been set before.
pub fn lock_config() -> Result<ApiLockGuard, Error> {
- instance().lock_config()
+ instance().lock()
}
/// Return contents of the remotes config
///
/// Will panic if the the remote config instance has not been set before.
pub fn config() -> Result<(SectionConfigData<Remote>, ConfigDigest), Error> {
- instance().config()
+ instance().read()
}
pub fn get_secret_token(remote: &Remote) -> Result<String, Error> {
- instance().get_secret_token(remote)
+ instance().read_secret_token(remote)
}
/// 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> {
- instance().save_config(config)
+ instance().write(config)
}
pub trait RemoteConfig {
/// Return contents of the remotes config
- fn config(&self) -> Result<(SectionConfigData<Remote>, ConfigDigest), Error>;
+ fn read(&self) -> Result<(SectionConfigData<Remote>, ConfigDigest), Error>;
/// Return contents of the remotes shadow config
- fn get_secret_token(&self, remote: &Remote) -> Result<String, Error>;
+ fn read_secret_token(&self, remote: &Remote) -> Result<String, Error>;
/// Lock the remotes config
- fn lock_config(&self) -> Result<ApiLockGuard, Error>;
+ fn lock(&self) -> Result<ApiLockGuard, Error>;
/// Replace the currently persisted remotes config
- fn save_config(&self, remotes: SectionConfigData<Remote>) -> Result<(), Error>;
+ fn write(&self, remotes: SectionConfigData<Remote>) -> Result<(), Error>;
}
/// Default, production implementation for reading/writing the `remotes.cfg`
@@ -72,11 +72,11 @@ pub trait RemoteConfig {
pub struct DefaultRemoteConfig;
impl RemoteConfig for DefaultRemoteConfig {
- fn lock_config(&self) -> Result<ApiLockGuard, Error> {
+ fn lock(&self) -> Result<ApiLockGuard, Error> {
open_api_lockfile(REMOTES_CFG_LOCKFILE, None, true)
}
- fn config(&self) -> Result<(SectionConfigData<Remote>, ConfigDigest), Error> {
+ fn read(&self) -> Result<(SectionConfigData<Remote>, ConfigDigest), Error> {
let content =
proxmox_sys::fs::file_read_optional_string(REMOTES_CFG_FILENAME)?.unwrap_or_default();
@@ -86,7 +86,7 @@ impl RemoteConfig for DefaultRemoteConfig {
Ok((data, digest.into()))
}
- fn save_config(&self, mut config: SectionConfigData<Remote>) -> Result<(), Error> {
+ fn write(&self, mut config: SectionConfigData<Remote>) -> Result<(), Error> {
let shadow_content = proxmox_sys::fs::file_read_optional_string(REMOTES_SHADOW_FILENAME)?
.unwrap_or_default();
@@ -135,7 +135,7 @@ impl RemoteConfig for DefaultRemoteConfig {
replace_config(REMOTES_CFG_FILENAME, raw.as_bytes())
}
- fn get_secret_token(&self, remote: &Remote) -> Result<String, Error> {
+ fn read_secret_token(&self, remote: &Remote) -> Result<String, Error> {
// not yet rewritten into shadow config
if remote.token != "-" {
return Ok(remote.token.clone());
diff --git a/server/src/test_support/fake_remote.rs b/server/src/test_support/fake_remote.rs
index e13ffa43..f387029f 100644
--- a/server/src/test_support/fake_remote.rs
+++ b/server/src/test_support/fake_remote.rs
@@ -35,7 +35,7 @@ pub struct FakeRemoteConfig {
}
impl RemoteConfig for FakeRemoteConfig {
- fn config(&self) -> Result<(SectionConfigData<Remote>, ConfigDigest), Error> {
+ fn read(&self) -> Result<(SectionConfigData<Remote>, ConfigDigest), Error> {
let mut section_config = SectionConfigData::default();
for i in 0..self.nr_of_pve_remotes {
@@ -59,15 +59,15 @@ impl RemoteConfig for FakeRemoteConfig {
Ok((section_config, digest))
}
- fn lock_config(&self) -> Result<ApiLockGuard, Error> {
+ fn lock(&self) -> Result<ApiLockGuard, Error> {
unsafe { Ok(proxmox_product_config::create_mocked_lock()) }
}
- fn save_config(&self, _remotes: SectionConfigData<Remote>) -> Result<(), Error> {
+ fn write(&self, _remotes: SectionConfigData<Remote>) -> Result<(), Error> {
Ok(())
}
- fn get_secret_token(&self, _remote: &Remote) -> Result<String, Error> {
+ fn read_secret_token(&self, _remote: &Remote) -> Result<String, Error> {
Ok(String::new())
}
}
--
2.47.3
next prev parent reply other threads:[~2026-08-27 11:43 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-27 11:42 [PATCH datacenter-manager/proxmox v3 00/21] inject application context via API macro for easier integration testing Lukas Wagner
2026-08-27 11:42 ` [PATCH proxmox v3 01/21] router: introduce shared state Lukas Wagner
2026-08-27 11:42 ` [PATCH proxmox v3 02/21] rest-server: allow to inject " Lukas Wagner
2026-08-27 11:42 ` [PATCH proxmox v3 03/21] api-macro: support shared state extraction type Lukas Wagner
2026-08-27 11:42 ` [PATCH proxmox v3 04/21] product-config: add ProductConfig type Lukas Wagner
2026-08-27 11:42 ` [PATCH datacenter-manager v3 05/21] context: promote context to a dir-style module Lukas Wagner
2026-08-27 11:42 ` Lukas Wagner [this message]
2026-08-27 11:42 ` [PATCH datacenter-manager v3 07/21] pdm-config: subscriptions: rename trait methods to read/write/lock Lukas Wagner
2026-08-27 11:42 ` [PATCH datacenter-manager v3 08/21] remote iterator: pass remote config reader explicitly Lukas Wagner
2026-08-27 11:42 ` [PATCH datacenter-manager v3 09/21] context: introduce a ContextFactory to build application context Lukas Wagner
2026-08-27 11:42 ` [PATCH datacenter-manager v3 10/21] context: establish PdmApplication object Lukas Wagner
2026-08-27 11:42 ` [PATCH datacenter-manager v3 11/21] context: register PdmApplication in router Lukas Wagner
2026-08-27 11:42 ` [PATCH datacenter-manager v3 12/21] connection: use client factory from PdmApplication handle Lukas Wagner
2026-08-27 11:42 ` [PATCH datacenter-manager v3 13/21] parallel fetcher: pass arguments to closure in a single type Lukas Wagner
2026-08-27 11:42 ` [PATCH datacenter-manager v3 14/21] server: migrate existing ParallelFetcher users to use PdmApplication Lukas Wagner
2026-08-27 11:42 ` [PATCH datacenter-manager v3 15/21] tests: add helpers for building API-handler-level integration tests Lukas Wagner
2026-08-27 11:42 ` [PATCH datacenter-manager v3 16/21] tests: add example tests for SDN API routes Lukas Wagner
2026-08-27 11:42 ` [PATCH datacenter-manager v3 17/21] api-cache: add wrapper type Lukas Wagner
2026-08-27 11:42 ` [PATCH datacenter-manager v3 18/21] context: provide api-cache on the app object Lukas Wagner
2026-08-27 11:42 ` [PATCH datacenter-manager v3 19/21] api: subscriptions: use PdmApplication instead of globals Lukas Wagner
2026-08-27 11:42 ` [PATCH datacenter-manager v3 20/21] pdm-config: subscriptions: drop unused accessor functions Lukas Wagner
2026-08-27 11:42 ` [PATCH datacenter-manager v3 21/21] tests: add example tests for remote subscription management Lukas Wagner
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=20260827114244.424784-7-l.wagner@proxmox.com \
--to=l.wagner@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox