acme-api: remove lazy_static dependency

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
This commit is contained in:
Maximiliano Sandoval 2024-08-14 09:19:59 +02:00 committed by Wolfgang Bumiller
parent 0b19e344d7
commit 9530b75286
3 changed files with 7 additions and 13 deletions

View File

@ -7,6 +7,7 @@ license.workspace = true
repository.workspace = true repository.workspace = true
exclude.workspace = true exclude.workspace = true
description = "ACME API implementation" description = "ACME API implementation"
rust-version.workspace = true
[dependencies] [dependencies]
anyhow.workspace = true anyhow.workspace = true
@ -15,7 +16,6 @@ futures = { workspace = true, optional = true }
hex = { workspace = true, optional = true } hex = { workspace = true, optional = true }
http = { workspace = true, optional = true } http = { workspace = true, optional = true }
hyper = { workspace = true, optional = true } hyper = { workspace = true, optional = true }
lazy_static = { workspace = true, optional = true }
log = { workspace = true, optional = true } log = { workspace = true, optional = true }
nix = { workspace = true, optional = true } nix = { workspace = true, optional = true }
serde = { workspace = true, features = ["derive"] } serde = { workspace = true, features = ["derive"] }
@ -48,7 +48,6 @@ impl = [
"dep:hex", "dep:hex",
"dep:http", "dep:http",
"dep:hyper", "dep:hyper",
"dep:lazy_static",
"dep:libc", "dep:libc",
"dep:log", "dep:log",
"dep:nix", "dep:nix",

View File

@ -2,12 +2,10 @@
//! //!
//! Those schemas are provided by debian package "libproxmox-acme-plugins". //! Those schemas are provided by debian package "libproxmox-acme-plugins".
use std::sync::Arc; use std::sync::{Arc, LazyLock, Mutex};
use std::sync::Mutex;
use std::time::SystemTime; use std::time::SystemTime;
use anyhow::Error; use anyhow::Error;
use lazy_static::lazy_static;
use serde::Serialize; use serde::Serialize;
use serde_json::Value; 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> { pub fn get_cached_challenge_schemas() -> Result<ChallengeSchemaWrapper, Error> {
lazy_static! { static CACHE: LazyLock<Mutex<Option<(Arc<Vec<AcmeChallengeSchema>>, SystemTime)>>> =
static ref CACHE: Mutex<Option<(Arc<Vec<AcmeChallengeSchema>>, SystemTime)>> = LazyLock::new(|| Mutex::new(None));
Mutex::new(None);
}
// the actual loading code // the actual loading code
let mut last = CACHE.lock().unwrap(); let mut last = CACHE.lock().unwrap();

View File

@ -1,7 +1,8 @@
//! ACME plugin configuration helpers (SectionConfig implementation) //! ACME plugin configuration helpers (SectionConfig implementation)
use std::sync::LazyLock;
use anyhow::Error; use anyhow::Error;
use lazy_static::lazy_static;
use serde_json::Value; use serde_json::Value;
use proxmox_config_digest::ConfigDigest; use proxmox_config_digest::ConfigDigest;
@ -11,9 +12,7 @@ use proxmox_section_config::{SectionConfig, SectionConfigData, SectionConfigPlug
use crate::types::{DnsPlugin, StandalonePlugin, PLUGIN_ID_SCHEMA}; use crate::types::{DnsPlugin, StandalonePlugin, PLUGIN_ID_SCHEMA};
lazy_static! { static CONFIG: LazyLock<SectionConfig> = LazyLock::new(init);
static ref CONFIG: SectionConfig = init();
}
impl DnsPlugin { impl DnsPlugin {
pub fn decode_data(&self, output: &mut Vec<u8>) -> Result<(), Error> { pub fn decode_data(&self, output: &mut Vec<u8>) -> Result<(), Error> {