From ea1458923e8bff452904a5ce7b54b16af1facecd Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Mon, 10 May 2021 15:55:49 +0200 Subject: [PATCH] manager: acme plugin: auto-complete available DNS challenge types Signed-off-by: Thomas Lamprecht --- src/bin/proxmox_backup_manager/acme.rs | 1 + src/config/acme/mod.rs | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/src/bin/proxmox_backup_manager/acme.rs b/src/bin/proxmox_backup_manager/acme.rs index a42a7aa4..61ce12b5 100644 --- a/src/bin/proxmox_backup_manager/acme.rs +++ b/src/bin/proxmox_backup_manager/acme.rs @@ -343,6 +343,7 @@ pub fn plugin_cli() -> CommandLineInterface { "add", CliCommand::new(&API_METHOD_ADD_PLUGIN) .arg_param(&["type", "id"]) + .completion_cb("api", crate::config::acme::complete_acme_api_challenge_type) .completion_cb("type", crate::config::acme::complete_acme_plugin_type), ) .insert( diff --git a/src/config/acme/mod.rs b/src/config/acme/mod.rs index ca2d9671..142ed2df 100644 --- a/src/config/acme/mod.rs +++ b/src/config/acme/mod.rs @@ -161,3 +161,14 @@ pub fn complete_acme_plugin_type(_arg: &str, _param: &HashMap) - //"http".to_string(), // makes currently not realyl sense to create or the like ] } + +pub fn complete_acme_api_challenge_type(_arg: &str, param: &HashMap) -> Vec { + 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() + } +}