From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id AB4961FF0A8 for ; Thu, 20 Aug 2026 16:52:36 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 2EDC52161B; Thu, 20 Aug 2026 16:52:30 +0200 (CEST) From: Lukas Wagner To: pdm-devel@lists.proxmox.com Subject: [PATCH datacenter-manager v2 05/20] pdm-config: remotes: rename trait methods to read/write/lock Date: Thu, 20 Aug 2026 16:52:05 +0200 Message-ID: <20260820145220.418032-6-l.wagner@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260820145220.418032-1-l.wagner@proxmox.com> References: <20260820145220.418032-1-l.wagner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1787237518404 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.745 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: P3U54TEFD3IPJVGJOWWRX7LLI56NYGZL X-Message-ID-Hash: P3U54TEFD3IPJVGJOWWRX7LLI56NYGZL X-MailFrom: l.wagner@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox Datacenter Manager development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: 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 --- 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 { - 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, ConfigDigest), Error> { - instance().config() + instance().read() } pub fn get_secret_token(remote: &Remote) -> Result { - 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) -> Result<(), Error> { - instance().save_config(config) + instance().write(config) } pub trait RemoteConfig { /// Return contents of the remotes config - fn config(&self) -> Result<(SectionConfigData, ConfigDigest), Error>; + fn read(&self) -> Result<(SectionConfigData, ConfigDigest), Error>; /// Return contents of the remotes shadow config - fn get_secret_token(&self, remote: &Remote) -> Result; + fn read_secret_token(&self, remote: &Remote) -> Result; /// Lock the remotes config - fn lock_config(&self) -> Result; + fn lock(&self) -> Result; /// Replace the currently persisted remotes config - fn save_config(&self, remotes: SectionConfigData) -> Result<(), Error>; + fn write(&self, remotes: SectionConfigData) -> 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 { + fn lock(&self) -> Result { open_api_lockfile(REMOTES_CFG_LOCKFILE, None, true) } - fn config(&self) -> Result<(SectionConfigData, ConfigDigest), Error> { + fn read(&self) -> Result<(SectionConfigData, 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) -> Result<(), Error> { + fn write(&self, mut config: SectionConfigData) -> 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 { + fn read_secret_token(&self, remote: &Remote) -> Result { // 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, ConfigDigest), Error> { + fn read(&self) -> Result<(SectionConfigData, 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 { + fn lock(&self) -> Result { unsafe { Ok(proxmox_product_config::create_mocked_lock()) } } - fn save_config(&self, _remotes: SectionConfigData) -> Result<(), Error> { + fn write(&self, _remotes: SectionConfigData) -> Result<(), Error> { Ok(()) } - fn get_secret_token(&self, _remote: &Remote) -> Result { + fn read_secret_token(&self, _remote: &Remote) -> Result { Ok(String::new()) } } -- 2.47.3