From 38b4f9b5346f325d5046f0aeb2d54cd43b7629ab Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Tue, 11 May 2021 17:33:06 +0200 Subject: [PATCH] config: acme: fall-back to the "default" account syncs behavior with both, the displayed state in the PBS web-interface, and the behavior of PVE/PMG. Without this a standard setup would result in a Error like: > TASK ERROR: no acme client configured which was pretty confusing, as the actual error was something else (no account configured), and the web-interface showed "default" as selected account, so a user had no idea what actually was wrong and how to fix it. Signed-off-by: Thomas Lamprecht --- src/config/node.rs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/config/node.rs b/src/config/node.rs index 31a2c5ab..3add8a2a 100644 --- a/src/config/node.rs +++ b/src/config/node.rs @@ -2,7 +2,7 @@ use std::collections::HashSet; use std::fs::File; use std::time::Duration; -use anyhow::{bail, format_err, Error}; +use anyhow::{bail, Error}; use nix::sys::stat::Mode; use serde::{Deserialize, Serialize}; @@ -138,13 +138,12 @@ impl NodeConfig { } pub async fn acme_client(&self) -> Result { - AcmeClient::load( - &self - .acme_config() - .ok_or_else(|| format_err!("no acme client configured"))?? - .account, - ) - .await + let account = if let Some(cfg) = self.acme_config().transpose()? { + cfg.account + } else { + AcmeAccountName::from_string("default".to_string())? // should really not happen + }; + AcmeClient::load(&account).await } pub fn acme_domains(&self) -> AcmeDomainIter {