diff options
Diffstat (limited to 'src/config/runtime.rs')
-rw-r--r-- | src/config/runtime.rs | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/config/runtime.rs b/src/config/runtime.rs index 6649d39..58c86b9 100644 --- a/src/config/runtime.rs +++ b/src/config/runtime.rs @@ -9,25 +9,30 @@ use crate::config::{ConfigOpts, ConfigOptsAcme, ConfigOptsBase, ConfigOptsConsul // In this file, we take ConfigOpts and transform them into ready-to-use RuntimeConfig. // We apply default values and business logic. +#[derive(Debug)] pub struct RuntimeConfigAcme { pub email: String, } +#[derive(Debug)] pub struct RuntimeConfigConsul { pub node_name: String, pub url: String, } +#[derive(Debug)] pub struct RuntimeConfigFirewall { pub refresh_time: Duration, } +#[derive(Debug)] pub struct RuntimeConfigIgd { pub private_ip: String, pub expiration_time: Duration, pub refresh_time: Duration, } +#[derive(Debug)] pub struct RuntimeConfig { pub acme: Option<RuntimeConfigAcme>, pub consul: RuntimeConfigConsul, @@ -57,7 +62,9 @@ impl RuntimeConfigAcme { return Ok(None); } - let email = opts.email.unwrap(); + let email = opts.email.expect( + "'DIPLONAT_ACME_EMAIL' environment variable is required \ + if 'DIPLONAT_ACME_ENABLE' == 'true'"); Ok(Some(Self { email, @@ -67,7 +74,8 @@ impl RuntimeConfigAcme { impl RuntimeConfigConsul { pub(super) fn new(opts: ConfigOptsConsul) -> Result<Self> { - let node_name = opts.node_name.unwrap(); + let node_name = opts.node_name.expect( + "'DIPLONAT_CONSUL_NODE_NAME' environment variable is required"); let url = opts.url.unwrap_or(super::CONSUL_URL.to_string()); Ok(Self { @@ -90,7 +98,8 @@ impl RuntimeConfigFirewall { impl RuntimeConfigIgd { pub(super) fn new(opts: ConfigOptsBase) -> Result<Self> { - let private_ip = opts.private_ip.unwrap(); + let private_ip = opts.private_ip.expect( + "'DIPLONAT_PRIVATE_IP' environment variable is required"); let expiration_time = Duration::from_secs( opts.expiration_time.unwrap_or(super::EXPIRATION_TIME).into()); let refresh_time = Duration::from_secs( |