[pbs-devel] [PATCH proxmox v6 1/3] acme-api: add ACME completion helpers
Samuel Rufinatscha
s.rufinatscha at proxmox.com
Fri Jan 16 12:28:55 CET 2026
Factors out the PBS ACME completion helpers and adds them to
proxmox-acme-api.
Signed-off-by: Samuel Rufinatscha <s.rufinatscha at proxmox.com>
---
proxmox-acme-api/src/challenge_schemas.rs | 2 +-
proxmox-acme-api/src/lib.rs | 57 +++++++++++++++++++++++
2 files changed, 58 insertions(+), 1 deletion(-)
diff --git a/proxmox-acme-api/src/challenge_schemas.rs b/proxmox-acme-api/src/challenge_schemas.rs
index e66e327e..4e94d3ff 100644
--- a/proxmox-acme-api/src/challenge_schemas.rs
+++ b/proxmox-acme-api/src/challenge_schemas.rs
@@ -29,7 +29,7 @@ impl Serialize for ChallengeSchemaWrapper {
}
}
-fn load_dns_challenge_schema() -> Result<Vec<AcmeChallengeSchema>, Error> {
+pub(crate) fn load_dns_challenge_schema() -> Result<Vec<AcmeChallengeSchema>, Error> {
let raw = file_read_string(ACME_DNS_SCHEMA_FN)?;
let schemas: serde_json::Map<String, Value> = serde_json::from_str(&raw)?;
diff --git a/proxmox-acme-api/src/lib.rs b/proxmox-acme-api/src/lib.rs
index 623e9e23..ba64569d 100644
--- a/proxmox-acme-api/src/lib.rs
+++ b/proxmox-acme-api/src/lib.rs
@@ -46,3 +46,60 @@ pub(crate) mod acme_plugin;
mod certificate_helpers;
#[cfg(feature = "impl")]
pub use certificate_helpers::{create_self_signed_cert, order_certificate, revoke_certificate};
+
+#[cfg(feature = "impl")]
+pub mod completion {
+
+ use std::collections::HashMap;
+ use std::ops::ControlFlow;
+
+ use crate::account_config::foreach_acme_account;
+ use crate::challenge_schemas::load_dns_challenge_schema;
+ use crate::plugin_config::plugin_config;
+
+ pub fn complete_acme_account(_arg: &str, _param: &HashMap<String, String>) -> Vec<String> {
+ let mut out = Vec::new();
+ let _ = foreach_acme_account(|name| {
+ out.push(name.into_string());
+ ControlFlow::Continue(())
+ });
+ out
+ }
+
+ pub fn complete_acme_plugin(_arg: &str, _param: &HashMap<String, String>) -> Vec<String> {
+ match plugin_config() {
+ Ok((config, _digest)) => config
+ .iter()
+ .map(|(id, (_type, _cfg))| id.clone())
+ .collect(),
+ Err(_) => Vec::new(),
+ }
+ }
+
+ pub fn complete_acme_plugin_type(_arg: &str, _param: &HashMap<String, String>) -> Vec<String> {
+ vec![
+ "dns".to_string(),
+ //"http".to_string(), // makes currently not really sense to create or the like
+ ]
+ }
+
+ pub fn complete_acme_api_challenge_type(
+ _arg: &str,
+ param: &HashMap<String, String>,
+ ) -> Vec<String> {
+ if param.get("type") == Some(&"dns".to_string()) {
+ match load_dns_challenge_schema() {
+ Ok(schema) => schema.into_iter().map(|s| s.id).collect(),
+ Err(_) => Vec::new(),
+ }
+ } else {
+ Vec::new()
+ }
+ }
+}
+
+#[cfg(feature = "impl")]
+pub use completion::{
+ complete_acme_account, complete_acme_api_challenge_type, complete_acme_plugin,
+ complete_acme_plugin_type,
+};
--
2.47.3
More information about the pbs-devel
mailing list