From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <pbs-devel-bounces@lists.proxmox.com>
Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9])
	by lore.proxmox.com (Postfix) with ESMTPS id 32E841FF167
	for <inbox@lore.proxmox.com>; Wed, 14 Aug 2024 09:20:27 +0200 (CEST)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
	by firstgate.proxmox.com (Proxmox) with ESMTP id 9E9DFFEA5;
	Wed, 14 Aug 2024 09:20:41 +0200 (CEST)
From: Maximiliano Sandoval <m.sandoval@proxmox.com>
To: pbs-devel@lists.proxmox.com
Date: Wed, 14 Aug 2024 09:19:59 +0200
Message-Id: <20240814072001.53422-10-m.sandoval@proxmox.com>
X-Mailer: git-send-email 2.39.2
In-Reply-To: <20240814072001.53422-1-m.sandoval@proxmox.com>
References: <20240814072001.53422-1-m.sandoval@proxmox.com>
MIME-Version: 1.0
X-SPAM-LEVEL: Spam detection results:  0
 AWL 0.111 Adjusted score from AWL reputation of From: address
 BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
 DMARC_MISSING             0.1 Missing DMARC policy
 KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment
 SPF_HELO_NONE           0.001 SPF: HELO does not publish an SPF Record
 SPF_PASS               -0.001 SPF: sender matches SPF record
 T_SCC_BODY_TEXT_LINE    -0.01 -
Subject: [pbs-devel] [PATCH proxmox v2 10/12] acme-api: remove lazy_static
 dependency
X-BeenThere: pbs-devel@lists.proxmox.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Proxmox Backup Server development discussion
 <pbs-devel.lists.proxmox.com>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pbs-devel>, 
 <mailto:pbs-devel-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/pbs-devel/>
List-Post: <mailto:pbs-devel@lists.proxmox.com>
List-Help: <mailto:pbs-devel-request@lists.proxmox.com?subject=help>
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel>, 
 <mailto:pbs-devel-request@lists.proxmox.com?subject=subscribe>
Reply-To: Proxmox Backup Server development discussion
 <pbs-devel@lists.proxmox.com>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: pbs-devel-bounces@lists.proxmox.com
Sender: "pbs-devel" <pbs-devel-bounces@lists.proxmox.com>

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
 proxmox-acme-api/Cargo.toml               |  3 +--
 proxmox-acme-api/src/challenge_schemas.rs | 10 +++-------
 proxmox-acme-api/src/plugin_config.rs     |  7 +++----
 3 files changed, 7 insertions(+), 13 deletions(-)

diff --git a/proxmox-acme-api/Cargo.toml b/proxmox-acme-api/Cargo.toml
index 13ace495..d00d8ab7 100644
--- a/proxmox-acme-api/Cargo.toml
+++ b/proxmox-acme-api/Cargo.toml
@@ -7,6 +7,7 @@ license.workspace = true
 repository.workspace = true
 exclude.workspace = true
 description = "ACME API implementation"
+rust-version.workspace = true
 
 [dependencies]
 anyhow.workspace = true
@@ -15,7 +16,6 @@ futures = { workspace = true, optional = true }
 hex = { workspace = true, optional = true }
 http = { workspace = true, optional = true }
 hyper = { workspace = true, optional = true }
-lazy_static = { workspace = true, optional = true }
 log = { workspace = true, optional = true }
 nix = { workspace = true, optional = true }
 serde = { workspace = true, features = ["derive"] }
@@ -48,7 +48,6 @@ impl = [
     "dep:hex",
     "dep:http",
     "dep:hyper",
-    "dep:lazy_static",
     "dep:libc",
     "dep:log",
     "dep:nix",
diff --git a/proxmox-acme-api/src/challenge_schemas.rs b/proxmox-acme-api/src/challenge_schemas.rs
index 6e1217c8..40a6a6af 100644
--- a/proxmox-acme-api/src/challenge_schemas.rs
+++ b/proxmox-acme-api/src/challenge_schemas.rs
@@ -2,12 +2,10 @@
 //!
 //! Those schemas are provided by debian  package "libproxmox-acme-plugins".
 
-use std::sync::Arc;
-use std::sync::Mutex;
+use std::sync::{Arc, LazyLock, Mutex};
 use std::time::SystemTime;
 
 use anyhow::Error;
-use lazy_static::lazy_static;
 use serde::Serialize;
 use serde_json::Value;
 
@@ -51,10 +49,8 @@ fn load_dns_challenge_schema() -> Result<Vec<AcmeChallengeSchema>, Error> {
 }
 
 pub fn get_cached_challenge_schemas() -> Result<ChallengeSchemaWrapper, Error> {
-    lazy_static! {
-        static ref CACHE: Mutex<Option<(Arc<Vec<AcmeChallengeSchema>>, SystemTime)>> =
-            Mutex::new(None);
-    }
+    static CACHE: LazyLock<Mutex<Option<(Arc<Vec<AcmeChallengeSchema>>, SystemTime)>>> =
+        LazyLock::new(|| Mutex::new(None));
 
     // the actual loading code
     let mut last = CACHE.lock().unwrap();
diff --git a/proxmox-acme-api/src/plugin_config.rs b/proxmox-acme-api/src/plugin_config.rs
index d75bea59..b7ed7594 100644
--- a/proxmox-acme-api/src/plugin_config.rs
+++ b/proxmox-acme-api/src/plugin_config.rs
@@ -1,7 +1,8 @@
 //! ACME plugin configuration helpers (SectionConfig implementation)
 
+use std::sync::LazyLock;
+
 use anyhow::Error;
-use lazy_static::lazy_static;
 use serde_json::Value;
 
 use proxmox_config_digest::ConfigDigest;
@@ -11,9 +12,7 @@ use proxmox_section_config::{SectionConfig, SectionConfigData, SectionConfigPlug
 
 use crate::types::{DnsPlugin, StandalonePlugin, PLUGIN_ID_SCHEMA};
 
-lazy_static! {
-    static ref CONFIG: SectionConfig = init();
-}
+static CONFIG: LazyLock<SectionConfig> = LazyLock::new(init);
 
 impl DnsPlugin {
     pub fn decode_data(&self, output: &mut Vec<u8>) -> Result<(), Error> {
-- 
2.39.2



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