public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Samuel Rufinatscha <s.rufinatscha@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox v6 1/3] acme-api: add ACME completion helpers
Date: Fri, 16 Jan 2026 12:28:55 +0100	[thread overview]
Message-ID: <20260116112859.194016-2-s.rufinatscha@proxmox.com> (raw)
In-Reply-To: <20260116112859.194016-1-s.rufinatscha@proxmox.com>

Factors out the PBS ACME completion helpers and adds them to
proxmox-acme-api.

Signed-off-by: Samuel Rufinatscha <s.rufinatscha@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



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


  reply	other threads:[~2026-01-16 11:29 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-16 11:28 [pbs-devel] [PATCH proxmox{, -backup} v6 0/5] fix #6939: acme: support servers returning 204 for nonce requests Samuel Rufinatscha
2026-01-16 11:28 ` Samuel Rufinatscha [this message]
2026-01-16 11:28 ` [pbs-devel] [PATCH proxmox v6 2/3] acme: introduce http_status module Samuel Rufinatscha
2026-01-16 11:28 ` [pbs-devel] [PATCH proxmox v6 3/3] fix #6939: acme: support servers returning 204 for nonce requests Samuel Rufinatscha
2026-01-16 11:28 ` [pbs-devel] [PATCH proxmox-backup v6 1/2] acme: remove local AcmeClient and use proxmox-acme-api handlers Samuel Rufinatscha
2026-01-16 11:28 ` [pbs-devel] [PATCH proxmox-backup v6 2/2] acme: remove unused src/acme and plugin code Samuel Rufinatscha

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=20260116112859.194016-2-s.rufinatscha@proxmox.com \
    --to=s.rufinatscha@proxmox.com \
    --cc=pbs-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
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal