From 4aac301852e3a1d73e59f933166d838469273e85 Mon Sep 17 00:00:00 2001 From: mbecker20 Date: Sat, 1 Apr 2023 19:35:04 +0000 Subject: [PATCH] 0.2.14 only try to merge files, filter nested directories --- Cargo.lock | 38 ++++++++++++++++----------------- cli/Cargo.toml | 2 +- core/Cargo.toml | 4 ++-- docs/servers.md | 14 ++++++++---- lib/db_client/Cargo.toml | 2 +- lib/helpers/Cargo.toml | 2 +- lib/monitor_client/Cargo.toml | 4 ++-- lib/periphery_client/Cargo.toml | 2 +- lib/types/Cargo.toml | 2 +- periphery/Cargo.toml | 4 ++-- periphery/src/config.rs | 1 - 11 files changed, 40 insertions(+), 35 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f43da7642..182ce1df4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -804,7 +804,7 @@ checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" [[package]] name = "core" -version = "0.2.13" +version = "0.2.14" dependencies = [ "anyhow", "async_timing_util", @@ -824,7 +824,7 @@ dependencies = [ "jwt", "merge_config_files", "monitor_helpers", - "monitor_types 0.2.13", + "monitor_types 0.2.14", "mungos", "periphery_client", "serde", @@ -1058,10 +1058,10 @@ checksum = "23d8666cb01533c39dde32bcbab8e227b4ed6679b2c925eba05feabea39508fb" [[package]] name = "db_client" -version = "0.2.13" +version = "0.2.14" dependencies = [ "anyhow", - "monitor_types 0.2.13", + "monitor_types 0.2.14", "mungos", ] @@ -1835,9 +1835,9 @@ dependencies = [ [[package]] name = "merge_config_files" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0eb90e0f8c47b81cd4bb84865e595ac3b0c5fabe6bf73bbd0507162b2fcc3c8a" +checksum = "48ed7c516ae04f732a7651e6bbbbdfd7762170fca6b6d263c14a105c41cab9a5" dependencies = [ "serde", "serde_json", @@ -1934,12 +1934,12 @@ dependencies = [ [[package]] name = "monitor_cli" -version = "0.2.13" +version = "0.2.14" dependencies = [ "async_timing_util", "clap", "colored", - "monitor_types 0.2.13", + "monitor_types 0.2.14", "rand", "run_command", "serde", @@ -1951,12 +1951,12 @@ dependencies = [ [[package]] name = "monitor_client" -version = "0.2.13" +version = "0.2.14" dependencies = [ "anyhow", "envy", "futures-util", - "monitor_types 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", + "monitor_types 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", "reqwest", "serde", "serde_derive", @@ -1968,11 +1968,11 @@ dependencies = [ [[package]] name = "monitor_helpers" -version = "0.2.13" +version = "0.2.14" dependencies = [ "anyhow", "axum", - "monitor_types 0.2.13", + "monitor_types 0.2.14", "rand", "serde", "serde_json", @@ -1981,7 +1981,7 @@ dependencies = [ [[package]] name = "monitor_periphery" -version = "0.2.13" +version = "0.2.14" dependencies = [ "anyhow", "async_timing_util", @@ -1994,7 +1994,7 @@ dependencies = [ "futures", "merge_config_files", "monitor_helpers", - "monitor_types 0.2.13", + "monitor_types 0.2.14", "run_command", "serde", "serde_derive", @@ -2008,7 +2008,7 @@ dependencies = [ [[package]] name = "monitor_types" -version = "0.2.13" +version = "0.2.14" dependencies = [ "anyhow", "bollard", @@ -2025,9 +2025,9 @@ dependencies = [ [[package]] name = "monitor_types" -version = "0.2.13" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16dc62e1626477f66340013650aebcd152ee14880b767f76359fbce2b0d621ed" +checksum = "19f0b594fa8c0af0c9d4ad7962a15782c7aa4afa575c60df69341f2de012e0c5" dependencies = [ "anyhow", "bollard", @@ -2268,11 +2268,11 @@ checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" [[package]] name = "periphery_client" -version = "0.2.13" +version = "0.2.14" dependencies = [ "anyhow", "futures-util", - "monitor_types 0.2.13", + "monitor_types 0.2.14", "reqwest", "serde", "serde_json", diff --git a/cli/Cargo.toml b/cli/Cargo.toml index c70e9d765..2bc763328 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "monitor_cli" -version = "0.2.13" +version = "0.2.14" edition = "2021" authors = ["MoghTech"] description = "monitor cli | tools to setup monitor system" diff --git a/core/Cargo.toml b/core/Cargo.toml index 43dc49480..4f7da6f6e 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "core" -version = "0.2.13" +version = "0.2.14" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -37,4 +37,4 @@ typeshare = "1.0.0" hex = "0.4" aws-config = "0.55" aws-sdk-ec2 = "0.25" -merge_config_files = "0.1.1" \ No newline at end of file +merge_config_files = "0.1.3" \ No newline at end of file diff --git a/docs/servers.md b/docs/servers.md index da79389ab..6a571efa9 100644 --- a/docs/servers.md +++ b/docs/servers.md @@ -13,7 +13,7 @@ The easiest way to do this is to follow the [monitor guide](https://github.com/m 1. Download the periphery binary from the latest [release](https://github.com/mbecker20/monitor/releases). - 2. Create and edit your config files, following the [config example](https://github.com/mbecker20/monitor/blob/main/config_example/periphery.config.example.toml). The monitor cli can be used to add the boilerplate: ```monitor periphery gen-config --path /path/to/config.toml```. The files can be anywhere, and can be passed to periphery via the ```--config-path``` flag. + 2. Create and edit your config files, following the [config example](https://github.com/mbecker20/monitor/blob/main/config_example/periphery.config.example.toml). The monitor cli can be used to add the boilerplate: ```monitor periphery gen-config --path /path/to/config.toml```. The files can be anywhere, and can be passed to periphery via the ```--config-path``` argument. 3. Ensure that inbound connectivity is allowed on the port specified in periphery.config.toml (default 8000). @@ -26,16 +26,22 @@ The easiest way to do this is to follow the [monitor guide](https://github.com/m ``` periphery \ --config-path /path/to/periphery.config.base.toml \ - --config-path /other_path/to/periphery.config.overide.toml \ + --config-path /other_path/to/overide-periphery-config-directory \ + --config-keyword periphery \ + --config-keyword config \ --merge-nested-config \ --home_dir /home/username ``` ## passing config files -when you pass multiple config files, later --config-path given in the command will always overide previous ones. +Either file paths or directory paths can be passed to ```--config-path```. -there are two ways to merge config files. The default behavior is to completely replace any base fields with whatever fields are present in the overide config. So if you pass ```allowed_ips = []``` in your overide config, the final allowed_ips will be an empty list as well. +When using directories, the file entries can be filtered by name with the ```--config-keyword``` argument, which can be passed multiple times to add more keywords. If passed, then only config files with file names that contain all keywords will be merged. + +When passing multiple config files, later --config-path given in the command will always overide previous ones. Directory config files are merged in alphabetical order by name, so ```config_b.toml``` will overide ```config_a.toml```. + +There are two ways to merge config files. The default behavior is to completely replace any base fields with whatever fields are present in the overide config. So if you pass ```allowed_ips = []``` in your overide config, the final allowed_ips will be an empty list as well. ```--merge-nested-config``` will merge config fields recursively and extend config array fields. diff --git a/lib/db_client/Cargo.toml b/lib/db_client/Cargo.toml index a89307143..84efecd8f 100644 --- a/lib/db_client/Cargo.toml +++ b/lib/db_client/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "db_client" -version = "0.2.13" +version = "0.2.14" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/lib/helpers/Cargo.toml b/lib/helpers/Cargo.toml index bcc5e8376..5d279d95c 100644 --- a/lib/helpers/Cargo.toml +++ b/lib/helpers/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "monitor_helpers" -version = "0.2.13" +version = "0.2.14" edition = "2021" authors = ["MoghTech"] description = "helpers used as dependency for mogh tech monitor" diff --git a/lib/monitor_client/Cargo.toml b/lib/monitor_client/Cargo.toml index b91927cb3..3f3bd259b 100644 --- a/lib/monitor_client/Cargo.toml +++ b/lib/monitor_client/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "monitor_client" -version = "0.2.13" +version = "0.2.14" edition = "2021" authors = ["MoghTech"] description = "a client to interact with the monitor system" @@ -9,7 +9,7 @@ license = "GPL-3.0-or-later" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -monitor_types = "0.2.13" +monitor_types = "0.2.14" reqwest = { version = "0.11", features = ["json"] } tokio-tungstenite = { version = "0.18", features=["native-tls"] } tokio = { version = "1.25", features = ["full"] } diff --git a/lib/periphery_client/Cargo.toml b/lib/periphery_client/Cargo.toml index 049762eca..29c40ceac 100644 --- a/lib/periphery_client/Cargo.toml +++ b/lib/periphery_client/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "periphery_client" -version = "0.2.13" +version = "0.2.14" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/lib/types/Cargo.toml b/lib/types/Cargo.toml index a28dbcab8..811abf7fc 100644 --- a/lib/types/Cargo.toml +++ b/lib/types/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "monitor_types" -version = "0.2.13" +version = "0.2.14" edition = "2021" authors = ["MoghTech"] description = "types for the mogh tech monitor" diff --git a/periphery/Cargo.toml b/periphery/Cargo.toml index 134bbe80c..989c1f97b 100644 --- a/periphery/Cargo.toml +++ b/periphery/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "monitor_periphery" -version = "0.2.13" +version = "0.2.14" edition = "2021" authors = ["MoghTech"] description = "monitor periphery binary" @@ -33,4 +33,4 @@ toml = "0.7" daemonize = "0.5.0" clap = { version = "4.2", features = ["derive"] } svi = "0.1.3" -merge_config_files = "0.1.2" +merge_config_files = "0.1.3" diff --git a/periphery/src/config.rs b/periphery/src/config.rs index 9b0926093..e079dab47 100644 --- a/periphery/src/config.rs +++ b/periphery/src/config.rs @@ -71,7 +71,6 @@ pub fn load() -> (Args, u16, PeripheryConfigExtension, HomeDirExtension) { .into_iter() .map(|p| p.replace("~", &home_dir)) .collect::>(); - println!("{config_paths:?}"); let env_match_keywords = parse_comma_seperated_list(env.config_keywords) .expect("failed to parse environemt CONFIG_KEYWORDS into comma seperated list"); let match_keywords = args