summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRina Fujino <18257209+rina23q@users.noreply.github.com>2022-04-11 16:41:02 +0200
committerRina Fujino <18257209+rina23q@users.noreply.github.com>2022-04-11 16:41:02 +0200
commit3e86cb3670da49def33f24a1cf9d4a72e24b0d9d (patch)
tree7736bb6117ec25ba7fffa456a0f15f952c3ea33e
parent351423b34cc679cbd5e27c30ea7cecd71ba3a5f9 (diff)
Remove default from some tedge config settigs
Signed-off-by: Rina Fujino <18257209+rina23q@users.noreply.github.com>
-rw-r--r--crates/common/tedge_config/src/settings.rs22
-rw-r--r--crates/common/tedge_config/src/tedge_config.rs36
-rw-r--r--crates/common/tedge_config/tests/test_tedge_config.rs5
-rw-r--r--crates/core/tedge/src/cli/config/config_key.rs6
-rw-r--r--crates/core/tedge_agent/src/agent.rs12
-rw-r--r--crates/core/tedge_mapper/src/main.rs2
6 files changed, 35 insertions, 48 deletions
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/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
@@ -57,9 +57,9 @@ impl ConfigKey {
config_key!(MqttExternalCertfileSetting),
config_key!(MqttExternalKeyfileSetting),
config_key!(SoftwarePluginDefaultSetting),
- config_key!(TmpPathDefaultSetting),
- config_key!(LogPathDefaultSetting),
- config_key!(RunPathDefaultSetting),
+ config_key!(TmpPathSetting),
+ config_key!(LogPathSetting),
+ config_key!(RunPathSetting),
]
}
}
diff --git a/crates/core/tedge_agent/src/agent.rs b/crates/core/tedge_agent/src/agent.rs
index 94b0b07f..ec2d80b6 100644
--- a/crates/core/tedge_agent/src/agent.rs
+++ b/crates/core/tedge_agent/src/agent.rs
@@ -20,9 +20,9 @@ use serde_json::json;
use std::process;
use std::{convert::TryInto, fmt::Debug, path::PathBuf, sync::Arc};
use tedge_config::{
- ConfigRepository, ConfigSettingAccessor, ConfigSettingAccessorStringExt, LogPathDefaultSetting,
- MqttBindAddressSetting, MqttPortSetting, RunPathDefaultSetting, SoftwarePluginDefaultSetting,
- TEdgeConfigLocation, TmpPathDefaultSetting, DEFAULT_LOG_PATH, DEFAULT_RUN_PATH,
+ ConfigRepository, ConfigSettingAccessor, ConfigSettingAccessorStringExt, LogPathSetting,
+ MqttBindAddressSetting, MqttPortSetting, RunPathSetting, SoftwarePluginDefaultSetting,
+ TEdgeConfigLocation, TmpPathSetting, DEFAULT_LOG_PATH, DEFAULT_RUN_PATH,
};
use tedge_utils::file::create_directory_with_user_group;
use tokio::sync::Mutex;
@@ -139,11 +139,11 @@ impl SmAgentConfig {
.tedge_config_root_path()
.to_path_buf();
- let tedge_download_dir = tedge_config.query_string(TmpPathDefaultSetting)?.into();
+ let tedge_download_dir = tedge_config.query_string(TmpPathSetting)?.into();
- let tedge_log_dir: String = tedge_config.query_string(LogPathDefaultSetting)?.into();
+ let tedge_log_dir: String = tedge_config.query_string(LogPathSetting)?.into();
let tedge_log_dir = PathBuf::from(&format!("{tedge_log_dir}/{AGENT_LOG_PATH}"));
- let tedge_run_dir = tedge_config.query_string(RunPathDefaultSetting)?.into();
+ let tedge_run_dir = tedge_config.query_string(RunPathSetting)?.into();
Ok(SmAgentConfig::default()
.with_sm_home(tedge_config_path)
diff --git a/crates/core/tedge_mapper/src/main.rs b/crates/core/tedge_mapper/src/main.rs
index 27339ba8..4b4a9f47 100644
--- a/crates/core/tedge_mapper/src/main.rs
+++ b/crates/core/tedge_mapper/src/main.rs
@@ -86,7 +86,7 @@ async fn main() -> anyhow::Result<()> {
// Run only one instance of a mapper
let _flock = check_another_instance_is_not_running(
&mapper_opt.name.to_string(),
- &config.query(RunPathDefaultSetting)?.into(),
+ &config.query(RunPathSetting)?.into(),
)?;
if mapper_opt.init {