From 7b84a345ef8468ae42c9ee134fba0ea00e994748 Mon Sep 17 00:00:00 2001 From: Robin Appelman <robin@icewind.nl> Date: Thu, 24 Jun 2021 15:47:59 +0200 Subject: [PATCH] make loading of additional config files optional Signed-off-by: Robin Appelman <robin@icewind.nl> --- Cargo.lock | 38 ++++++++++++++++++++------------------ appinfo/info.xml | 2 +- src/config.rs | 9 ++++++--- src/config/nc.rs | 7 ++++--- 4 files changed, 31 insertions(+), 25 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fbb19b1..0755d5e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,5 +1,7 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. +version = 3 + [[package]] name = "addr2line" version = "0.15.2" @@ -301,9 +303,9 @@ dependencies = [ [[package]] name = "combine" -version = "4.5.2" +version = "4.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc4369b5e4c0cddf64ad8981c0111e7df4f7078f4d6ba98fb31f2e17c4c57b7e" +checksum = "a2d47c1b11006b87e492b53b313bb699ce60e16613c4dddaa91f8f7c220ab2fa" dependencies = [ "bytes", "futures-util", @@ -314,9 +316,9 @@ dependencies = [ [[package]] name = "cpufeatures" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed00c67cb5d0a7d64a44f6ad2668db7e7530311dd53ea79bcd4fb022c64911c8" +checksum = "66c99696f6c9dd7f35d486b9d04d7e6e202aa3e8c40d553f2fdf5e7e0c6a71ef" dependencies = [ "libc", ] @@ -1099,9 +1101,9 @@ dependencies = [ [[package]] name = "nextcloud-config-parser" -version = "0.2.0" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4cb4342e9cc7e2094c9a5cf391b5d0c3716b1eb17fc01edcfa21dcba9050208" +checksum = "bb22eb22bf1814e2098e2536267917c41c4146d294a71924441e5b2b6d8fd101" dependencies = [ "php-literal-parser", "redis", @@ -1572,9 +1574,9 @@ dependencies = [ [[package]] name = "redis" -version = "0.20.1" +version = "0.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a32cb439c4e89c1e6415e5b3b23d9d8cc6dc1bf5a8cade19adbd5418de803be" +checksum = "d4f0ceb2ec0dd769483ecd283f6615aa83dcd0be556d5294c6e659caefe7cc54" dependencies = [ "async-trait", "bytes", @@ -1594,9 +1596,9 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.2.8" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "742739e41cd49414de871ea5e549afb7e2a3ac77b589bcbebe8c82fab37147fc" +checksum = "5ab49abadf3f9e1c4bc499e8845e152ad87d2ad2d30371841171169e9d75feee" dependencies = [ "bitflags", ] @@ -1657,9 +1659,9 @@ dependencies = [ [[package]] name = "reqwest" -version = "0.11.3" +version = "0.11.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2296f2fac53979e8ccbc4a1136b25dcefd37be9ed7e4a1f6b05a6029c84ff124" +checksum = "246e9f61b9bb77df069a947682be06e31ac43ea37862e244a69f177694ea6d22" dependencies = [ "base64 0.13.0", "bytes", @@ -1737,9 +1739,9 @@ dependencies = [ [[package]] name = "rustc-demangle" -version = "0.1.19" +version = "0.1.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "410f7acf3cb3a44527c5d9546bad4bf4e6c460915d5f9f2fc524498bfe8f70ce" +checksum = "dead70b0b5e03e9c814bcb6b01e03e68f7c57a80aa48c72ec92152ab3e818d49" [[package]] name = "rustls" @@ -2283,9 +2285,9 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" [[package]] name = "tokio" -version = "1.7.0" +version = "1.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c79ba603c337335df6ba6dd6afc38c38a7d5e1b0c871678439ea973cd62a118e" +checksum = "5fb2ed024293bb19f7a5dc54fe83bf86532a44c12a2bb8ba40d64a4509395ca2" dependencies = [ "autocfg 1.0.1", "bytes", @@ -2653,9 +2655,9 @@ checksum = "b4ae116fef2b7fea257ed6440d3cfcff7f190865f170cdad00bb6465bf18ecba" [[package]] name = "vcpkg" -version = "0.2.13" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "025ce40a007e1907e58d5bc1a594def78e5573bb0b1160bc389634e8f12e4faa" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" [[package]] name = "vec_map" diff --git a/appinfo/info.xml b/appinfo/info.xml index 5bdd328..e6ee3e3 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -7,7 +7,7 @@ <description>< for detailed setup instructions]]></description> - <version>0.2.0</version> + <version>0.2.1</version> <licence>agpl</licence> <author>Robin Appelman</author> <namespace>NotifyPush</namespace> diff --git a/src/config.rs b/src/config.rs index 93aca7c..1620644 100644 --- a/src/config.rs +++ b/src/config.rs @@ -65,6 +65,9 @@ pub struct Opt { /// Disable ansi escape sequences in logging output #[structopt(long)] pub no_ansi: bool, + /// Load other files named *.config.php in the config folder + #[structopt(long)] + pub glob_config: bool, } #[derive(Debug)] @@ -171,7 +174,7 @@ impl Config { let from_config = opt .config_file .as_ref() - .map(PartialConfig::from_file) + .map(|path| PartialConfig::from_file(path, opt.glob_config)) .transpose()? .unwrap_or_default(); let from_env = PartialConfig::from_env()?; @@ -232,8 +235,8 @@ impl PartialConfig { }) } - fn from_file(file: impl AsRef<Path>) -> Result<Self> { - parse_config_file(file) + fn from_file(file: impl AsRef<Path>, glob: bool) -> Result<Self> { + parse_config_file(file, glob) } fn from_opt(opt: Opt) -> Self { diff --git a/src/config/nc.rs b/src/config/nc.rs index 37661ac..3d64cfa 100644 --- a/src/config/nc.rs +++ b/src/config/nc.rs @@ -1,10 +1,11 @@ use crate::config::PartialConfig; use color_eyre::{eyre::WrapErr, Result}; -use nextcloud_config_parser::parse; +use nextcloud_config_parser::{parse, parse_glob}; use std::path::Path; -pub(super) fn parse_config_file(path: impl AsRef<Path>) -> Result<PartialConfig> { - let config = parse(path).wrap_err("Failed to parse nextcloud config")?; +pub(super) fn parse_config_file(path: impl AsRef<Path>, glob: bool) -> Result<PartialConfig> { + let config = if glob { parse(path) } else { parse_glob(path) } + .wrap_err("Failed to parse nextcloud config")?; Ok(PartialConfig { database: Some(config.database.into()), -- GitLab