diff options
author | Rina Fujino <18257209+rina23q@users.noreply.github.com> | 2022-04-26 15:00:06 +0200 |
---|---|---|
committer | Rina Fujino <18257209+rina23q@users.noreply.github.com> | 2022-04-26 15:00:06 +0200 |
commit | 224cb2f75bc0d897d2a266895eae48fc7107e83e (patch) | |
tree | daca3d154535ac4f3840371ff462347689201d75 /crates | |
parent | f5b2f5b224831cf47b454c202026c85aa1d0c7de (diff) | |
parent | 42dcd4ec556dba3ec2987895bd79c566c3c6546a (diff) |
Merge branch 'main' into feature/1030/configuration-management
Diffstat (limited to 'crates')
42 files changed, 285 insertions, 129 deletions
diff --git a/crates/common/batcher/Cargo.toml b/crates/common/batcher/Cargo.toml index 01ec3a34..5374e441 100644 --- a/crates/common/batcher/Cargo.toml +++ b/crates/common/batcher/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "batcher" -version = "0.6.1" +version = "0.6.2" authors = ["thin-edge.io team <info@thin-edge.io>"] edition = "2021" rust-version = "1.58.1" diff --git a/crates/common/certificate/Cargo.toml b/crates/common/certificate/Cargo.toml index 6a39f109..532e961b 100644 --- a/crates/common/certificate/Cargo.toml +++ b/crates/common/certificate/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "certificate" -version = "0.6.1" +version = "0.6.2" authors = ["thin-edge.io team <info@thin-edge.io>"] edition = "2021" rust-version = "1.58.1" diff --git a/crates/common/clock/Cargo.toml b/crates/common/clock/Cargo.toml index 988c6b4d..a83c1c96 100644 --- a/crates/common/clock/Cargo.toml +++ b/crates/common/clock/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "clock" -version = "0.6.1" +version = "0.6.2" authors = ["thin-edge.io team <info@thin-edge.io>"] edition = "2021" rust-version = "1.58.1" diff --git a/crates/common/download/Cargo.toml b/crates/common/download/Cargo.toml index d6539039..4e991bfd 100644 --- a/crates/common/download/Cargo.toml +++ b/crates/common/download/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "download" -version = "0.6.1" +version = "0.6.2" authors = ["thin-edge.io team <info@thin-edge.io>"] edition = "2021" rust-version = "1.58.1" diff --git a/crates/common/flockfile/Cargo.toml b/crates/common/flockfile/Cargo.toml index 4d138379..a4ad4daa 100644 --- a/crates/common/flockfile/Cargo.toml +++ b/crates/common/flockfile/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "flockfile" -version = "0.6.1" +version = "0.6.2" authors = ["thin-edge.io team <info@thin-edge.io>"] edition = "2021" rust-version = "1.58.1" diff --git a/crates/common/json_writer/Cargo.toml b/crates/common/json_writer/Cargo.toml index 7e899eca..a352df19 100644 --- a/crates/common/json_writer/Cargo.toml +++ b/crates/common/json_writer/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "json-writer" -version = "0.6.1" +version = "0.6.2" authors = ["thin-edge.io team <info@thin-edge.io>"] edition = "2021" rust-version = "1.58.1" diff --git a/crates/common/logged_command/Cargo.toml b/crates/common/logged_command/Cargo.toml new file mode 100644 index 00000000..5a5df9c0 --- /dev/null +++ b/crates/common/logged_command/Cargo.toml @@ -0,0 +1,20 @@ +[package] +name = "logged_command" +version = "0.6.1" +authors = ["thin-edge.io team <info@thin-edge.io>"] +edition = "2021" +rust-version = "1.58.1" + +[dependencies] +async-trait = "0.1" +log = "0.4" +thiserror = "1.0" +tokio = { version = "1.8", features = [ "fs", "io-util", "macros", "process", "rt" ] } + + +[dev-dependencies] +anyhow = "1.0" +assert_matches = "1.5" +serial_test = "0.6" +tempfile = "3.2" +test-case = "2.0" diff --git a/crates/common/logged_command/src/lib.rs b/crates/common/logged_command/src/lib.rs new file mode 100644 index 00000000..1bd2fdf9 --- /dev/null +++ b/crates/common/logged_command/src/lib.rs @@ -0,0 +1,3 @@ +mod logged_command; + +pub use crate::logged_command::{LoggedCommand, LoggingChild}; diff --git a/crates/core/plugin_sm/src/logged_command.rs b/crates/common/logged_command/src/logged_command.rs index 11739ce0..08ce5990 100644 --- a/crates/core/plugin_sm/src/logged_command.rs +++ b/crates/common/logged_command/src/logged_command.rs @@ -1,8 +1,13 @@ -use std::ffi::OsStr; -use std::process::{Output, Stdio}; -use tokio::fs::File; -use tokio::io::{AsyncWriteExt, BufWriter}; -use tokio::process::{Child, Command}; +use log::error; +use std::{ + ffi::OsStr, + process::{Output, Stdio}, +}; +use tokio::{ + fs::File, + io::{AsyncWriteExt, BufWriter}, + process::{Child, Command}, +}; pub struct LoggingChild { command_line: String, @@ -16,7 +21,7 @@ impl LoggingChild { ) -> Result<Output, std::io::Error> { let outcome = self.inner_child.wait_with_output().await; if let Err(err) = LoggedCommand::log_outcome(&self.command_line, &outcome, logger).await { - tracing::log::error!("Fail to log the command execution: {}", err); + error!("Fail to log the command execution: {}", err); } outcome @@ -80,7 +85,7 @@ impl LoggedCommand { let outcome = self.command.output().await; if let Err(err) = LoggedCommand::log_outcome(&self.command_line, &outcome, logger).await { - tracing::log::error!("Fail to log the command execution: {}", err); + error!("Fail to log the command execution: {}", err); } outcome diff --git a/crates/common/mqtt_channel/Cargo.toml b/crates/common/mqtt_channel/Cargo.toml index 2a0c86d0..41941935 100644 --- a/crates/common/mqtt_channel/Cargo.toml +++ b/crates/common/mqtt_channel/Cargo.toml @@ -3,7 +3,7 @@ name = "mqtt_channel" authors = ["thin-edge.io team <info@thin-edge.io>"] edition = "2021" rust-version = "1.58.1" -version = "0.6.1" +version = "0.6.2" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/crates/common/tedge_config/Cargo.toml b/crates/common/tedge_config/Cargo.toml index 59acdf8f..7f5d92af 100644 --- a/crates/common/tedge_config/Cargo.toml +++ b/crates/common/tedge_config/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tedge_config" -version = "0.6.1" +version = "0.6.2" authors = ["thin-edge.io team <info@thin-edge.io>"] edition = "2021" rust-version = "1.58.1" diff --git a/crates/common/tedge_config/src/settings.rs b/crates/common/tedge_config/src/settings.rs index 42a3f0f3..fb018408 100644 --- a/crates/common/tedge_config/src/settings.rs +++ b/crates/common/tedge_config/src/settings.rs @@ -288,37 +288,39 @@ impl ConfigSetting for SoftwarePluginDefaultSetting { } #[derive(Debug, Copy, Clone, Eq, PartialEq)] -pub struct TmpPathDefaultSetting; +pub struct TmpPathSetting; -impl ConfigSetting for TmpPathDefaultSetting { +impl ConfigSetting for TmpPathSetting { const KEY: &'static str = "tmp.path"; const DESCRIPTION: &'static str = concat!( - "The default temporary path to be used for downloads on the device", + "The temporary directory path to be used for downloads on the device", "Example: /tmp" ); type Value = FilePath; } -pub struct LogPathDefaultSetting; +pub struct LogPathSetting; -impl ConfigSetting for LogPathDefaultSetting { +impl ConfigSetting for LogPathSetting { const KEY: &'static str = "logs.path"; - const DESCRIPTION: &'static str = - concat!("The default path to be used for logs", "Example: /var/log"); + const DESCRIPTION: &'static str = concat!( + "The directory path to be used for logs", + "Example: /var/log" + ); type Value = FilePath; } -pub struct RunPathDefaultSetting; +pub struct RunPathSetting; -impl ConfigSetting for RunPathDefaultSetting { +impl ConfigSetting for RunPathSetting { const KEY: &'static str = "run.path"; const DESCRIPTION: &'static str = concat!( - "The default path to be used for runtime information", + "The directory path to be used for runtime information", "Example: /run" ); diff --git a/crates/common/tedge_config/src/tedge_config.rs b/crates/common/tedge_config/src/tedge_config.rs index 0c403087..f37ea0e3 100644 --- a/crates/common/tedge_config/src/tedge_config.rs +++ b/crates/common/tedge_config/src/tedge_config.rs @@ -509,8 +509,8 @@ where } } -impl ConfigSettingAccessor<TmpPathDefaultSetting> for TEdgeConfig { - fn query(&self, _setting: TmpPathDefaultSetting) -> ConfigSettingResult<FilePath> { +impl ConfigSettingAccessor<TmpPathSetting> for TEdgeConfig { + fn query(&self, _setting: TmpPathSetting) -> ConfigSettingResult<FilePath> { Ok(self .data .tmp @@ -519,23 +519,19 @@ impl ConfigSettingAccessor<TmpPathDefaultSetting> for TEdgeConfig { .unwrap_or_else(|| self.config_defaults.default_tmp_path.clone())) } - fn update( - &mut self, - _setting: TmpPathDefaultSetting, - value: FilePath, - ) -> ConfigSettingResult<()> { + fn update(&mut self, _setting: TmpPathSetting, value: FilePath) -> ConfigSettingResult<()> { self.data.tmp.dir_path = Some(value); Ok(()) } - fn unset(&mut self, _setting: TmpPathDefaultSetting) -> ConfigSettingResult<()> { + fn unset(&mut self, _setting: TmpPathSetting) -> ConfigSettingResult<()> { self.data.tmp.dir_path = None; Ok(()) } } -impl ConfigSettingAccessor<LogPathDefaultSetting> for TEdgeConfig { - fn query(&self, _setting: LogPathDefaultSetting) -> ConfigSettingResult<FilePath> { +impl ConfigSettingAccessor<LogPathSetting> for TEdgeConfig { + fn query(&self, _setting: LogPathSetting) -> ConfigSettingResult<FilePath> { Ok(self .data .logs @@ -544,23 +540,19 @@ impl ConfigSettingAccessor<LogPathDefaultSetting> for TEdgeConfig { .unwrap_or_else(|| self.config_defaults.default_logs_path.clone())) } - fn update( - &mut self, - _setting: LogPathDefaultSetting, - value: FilePath, - ) -> ConfigSettingResult<()> { + fn update(&mut self, _setting: LogPathSetting, value: FilePath) -> ConfigSettingResult<()> { self.data.logs.dir_path = Some(value); Ok(()) } - fn unset(&mut self, _setting: LogPathDefaultSetting) -> ConfigSettingResult<()> { + fn unset(&mut self, _setting: LogPathSetting) -> ConfigSettingResult<()> { self.data.logs.dir_path = None; Ok(()) } } -impl ConfigSettingAccessor<RunPathDefaultSetting> for TEdgeConfig { - fn query(&self, _setting: RunPathDefaultSetting) -> ConfigSettingResult<FilePath> { +impl ConfigSettingAccessor<RunPathSetting> for TEdgeConfig { + fn query(&self, _setting: RunPathSetting) -> ConfigSettingResult<FilePath> { Ok(self .data .run @@ -569,16 +561,12 @@ impl ConfigSettingAccessor<RunPathDefaultSetting> for TEdgeConfig { .unwrap_or_else(|| self.config_defaults.default_run_path.clone())) } - fn update( - &mut self, - _setting: RunPathDefaultSetting, - value: FilePath, - ) -> ConfigSettingResult<()> { + fn update(&mut self, _setting: RunPathSetting, value: FilePath) -> ConfigSettingResult<()> { self.data.run.dir_path = Some(value); Ok(()) } - fn unset(&mut self, _setting: RunPathDefaultSetting) -> ConfigSettingResult<()> { + fn unset(&mut self, _setting: RunPathSetting) -> ConfigSettingResult<()> { self.data.run.dir_path = None; Ok(()) } diff --git a/crates/common/tedge_config/tests/test_tedge_config.rs b/crates/common/tedge_config/tests/test_tedge_config.rs index 61e59ac4..f39104ef 100644 --- a/crates/common/tedge_config/tests/test_tedge_config.rs +++ b/crates/common/tedge_config/tests/test_tedge_config.rs @@ -101,10 +101,7 @@ path = "/some/value" FilePath::from("key.pem") ); - assert_eq!( - config.query(TmpPathDefaultSetting)?, - FilePath::from("/some/value") - ); + assert_eq!(config.query(TmpPathSetting)?, FilePath::from("/some/value")); assert_eq!( config.query(MqttBindAddressSetting)?, diff --git a/crates/common/tedge_users/Cargo.toml b/crates/common/tedge_users/Cargo.toml index a1cddc44..74c3963e 100644 --- a/crates/common/tedge_users/Cargo.toml +++ b/crates/common/tedge_users/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tedge_users" -version = "0.6.1" +version = "0.6.2" authors = ["thin-edge.io team <info@thin-edge.io>"] edition = "2021" rust-version = "1.58.1" diff --git a/crates/common/tedge_users/src/lib.rs b/crates/common/tedge_users/src/lib.rs index d2065e8f..68ccc32e 100644 --- a/crates/common/tedge_users/src/lib.rs +++ b/crates/common/tedge_users/src/lib.rs @@ -12,7 +12,6 @@ pub use windows::*; pub const ROOT_USER: &str = "root"; pub const TEDGE_USER: &str = "tedge"; -pub const TEDGE_AGENT_USER: &str = "tedge-agent"; pub const BROKER_USER: &str = "mosquitto"; #[allow(dead_code)] // These errors are only raised from unix diff --git a/crates/common/tedge_utils/Cargo.toml b/crates/common/tedge_utils/Cargo.toml index dab4de47..746ee890 100644 --- a/crates/common/tedge_utils/Cargo.toml +++ b/crates/common/tedge_utils/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tedge_utils" -version = "0.6.1" +version = "0.6.2" authors = ["thin-edge.io team <info@thin-edge.io>"] edition = "2021" rust-version = "1.58.1" diff --git a/crates/core/agent_interface/Cargo.toml b/crates/core/agent_interface/Cargo.toml index 352f62b2..e7fb2d01 100644 --- a/crates/core/agent_interface/Cargo.toml +++ b/crates/core/agent_interface/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "agent_interface" -version = "0.6.1" +version = "0.6.2" authors = ["thin-edge.io team <info@thin-edge.io>"] edition = "2021" rust-version = "1.58.1" diff --git a/crates/core/c8y_api/Cargo.toml b/crates/core/c8y_api/Cargo.toml index 3d9e8036..aefbb6c5 100644 --- a/crates/core/c8y_api/Cargo.toml +++ b/crates/core/c8y_api/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "c8y_api" -version = "0.6.1" +version = "0.6.2" authors = ["thin-edge.io team <info@thin-edge.io>"] edition = "2021" rust-version = "1.58.1" diff --git a/crates/core/c8y_smartrest/Cargo.toml b/crates/core/c8y_smartrest/Cargo.toml index 5426da5e..3aed6de4 100644 --- a/crates/core/c8y_smartrest/Cargo.toml +++ b/crates/core/c8y_smartrest/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "c8y_smartrest" -version = "0.6.1" +version = "0.6.2" authors = ["thin-edge.io team <info@thin-edge.io>"] edition = "2021" rust-version = "1.58.1" diff --git a/crates/core/c8y_translator/Cargo.toml b/crates/core/c8y_translator/Cargo.toml index a8c427ec..b2aecfe3 100644 --- a/crates/core/c8y_translator/Cargo.toml +++ b/crates/core/c8y_translator/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "c8y_translator" -version = "0.6.1" +version = "0.6.2" authors = ["thin-edge.io team <info@thin-edge.io>"] edition = "2021" rust-version = "1.58.1" diff --git a/crates/core/c8y_translator/fuzz/Cargo.lock b/crates/core/c8y_translator/fuzz/Cargo.lock index e7a4927b..b9b5965d 100644 --- a/crates/core/c8y_translator/fuzz/Cargo.lock +++ b/crates/core/c8y_translator/fuzz/Cargo.lock @@ -25,7 +25,7 @@ checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" [[package]] name = "c8y_translator" -version = "0.6.1" +version = "0.6.2" dependencies = [ "clock", "json-writer", @@ -56,7 +56,7 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "clock" -version = "0.6.1" +version = "0.6.2" dependencies = [ "mockall", "time", @@ -97,7 +97,7 @@ checksum = "1aab8fc367588b89dcee83ab0fd66b72b50b72fa1904d7095045ace2b0c81c35" [[package]] name = "json-writer" -version = "0.6.1" +version = "0.6.2" dependencies = [ "serde_json", "thiserror", @@ -309,7 +309,7 @@ checksum = "507e9898683b6c43a9aa55b64259b721b52ba226e0f3779137e50ad114a4c90b" [[package]] name = "thin_edge_json" -version = "0.6.1" +version = "0.6.2" dependencies = [ "clock", "json-writer", diff --git a/crates/core/plugin_sm/Cargo.toml b/crates/core/plugin_sm/Cargo.toml index b246444d..e54837a1 100644 --- a/crates/core/plugin_sm/Cargo.toml +++ b/crates/core/plugin_sm/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "plugin_sm" -version = "0.6.1" +version = "0.6.2" authors = ["thin-edge.io team <info@thin-edge.io>"] edition = "2021" rust-version = "1.58.1" @@ -10,6 +10,7 @@ agent_interface = { path = "../agent_interface" } async-trait = "0.1" csv = "1.1" download = { path = "../../common/download" } +logged_command = { path = "../../common/logged_command" } serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" tedge_utils = { path = "../../common/tedge_utils" } diff --git a/crates/core/plugin_sm/src/lib.rs b/crates/core/plugin_sm/src/lib.rs index 79800999..c124bbbc 100644 --- a/crates/core/plugin_sm/src/lib.rs +++ b/crates/core/plugin_sm/src/lib.rs @@ -1,4 +1,3 @@ pub mod log_file; -pub mod logged_command; pub mod plugin; pub mod plugin_manager; diff --git a/crates/core/plugin_sm/src/plugin.rs b/crates/core/plugin_sm/src/plugin.rs index f7df5449..95ab2988 100644 --- a/crates/core/plugin_sm/src/plugin.rs +++ b/crates/core/plugin_sm/src/plugin.rs @@ -1,8 +1,8 @@ -use crate::logged_command::LoggedCommand; use agent_interface::*; use async_trait::async_trait; use csv::ReaderBuilder; use download::Downloader; +use logged_command::LoggedCommand; use serde::Deserialize; use std::path::Path; use std::{path::PathBuf, process::Output}; diff --git a/crates/core/tedge/Cargo.toml b/crates/core/tedge/Cargo.toml index 14b13d89..f236f29b 100644 --- a/crates/core/tedge/Cargo.toml +++ b/crates/core/tedge/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tedge" -version = "0.6.1" +version = "0.6.2" edition = "2021" rust-version = "1.58.1" authors = ["thin-edge.io team <info@thin-edge.io>"] @@ -9,7 +9,7 @@ readme = "README.md" description = "tedge is the cli tool for thin-edge.io" [package.metadata.deb] -depends = "mosquitto" +recommends = "mosquitto" maintainer-scripts = "../../../configuration/debian/tedge" [dependencies] diff --git a/crates/core/tedge/src/cli/config/config_key.rs b/crates/core/tedge/src/cli/config/config_key.rs index 064791a4..96227269 100644 --- a/crates/core/tedge/src/cli/config/config_key.rs +++ b/crates/core/tedge/src/cli/config/config_key.rs |