summaryrefslogtreecommitdiffstats
path: root/tedge_config
diff options
context:
space:
mode:
authorRina Fujino <18257209+rina23q@users.noreply.github.com>2021-06-02 16:02:48 +0200
committerGitHub <noreply@github.com>2021-06-02 16:02:48 +0200
commit26add5cf33a3b51bbb4f3ea0b4c862df716f30f1 (patch)
tree1f370098810dbf2a8c0b2da6f57a06e735837acf /tedge_config
parent650255e2442c6fd42fbf2db422616bc8bd486fff (diff)
[CIT-298] Make all Azure related commands consistent (#265)
- Rename config keys: azure.xxx -> az.xxx - Update docs and tests accordingly Signed-off-by: Rina Fujino <18257209+rina23q@users.noreply.github.com>
Diffstat (limited to 'tedge_config')
-rw-r--r--tedge_config/src/settings.rs34
-rw-r--r--tedge_config/src/tedge_config.rs18
-rw-r--r--tedge_config/src/tedge_config_dto.rs2
-rw-r--r--tedge_config/tests/test_tedge_config.rs9
4 files changed, 32 insertions, 31 deletions
diff --git a/tedge_config/src/settings.rs b/tedge_config/src/settings.rs
index 353db4c1..cff9541e 100644
--- a/tedge_config/src/settings.rs
+++ b/tedge_config/src/settings.rs
@@ -97,7 +97,7 @@ impl ConfigSetting for C8yRootCertPathSetting {
pub struct AzureUrlSetting;
impl ConfigSetting for AzureUrlSetting {
- const KEY: &'static str = "azure.url";
+ const KEY: &'static str = "az.url";
const DESCRIPTION: &'static str = concat!(
"Tenant endpoint URL of Azure IoT tenant. ",
@@ -116,7 +116,7 @@ impl ConfigSetting for AzureUrlSetting {
pub struct AzureRootCertPathSetting;
impl ConfigSetting for AzureRootCertPathSetting {
- const KEY: &'static str = "azure.root.cert.path";
+ const KEY: &'static str = "az.root.cert.path";
const DESCRIPTION: &'static str = concat!(
"Path where Azure IoT root certificate(s) are located. ",
@@ -126,20 +126,6 @@ impl ConfigSetting for AzureRootCertPathSetting {
type Value = FilePath;
}
-#[derive(Debug, Copy, Clone, Eq, PartialEq)]
-pub struct MqttPortSetting;
-
-impl ConfigSetting for MqttPortSetting {
- const KEY: &'static str = "mqtt.port";
-
- const DESCRIPTION: &'static str = concat!(
- "Mqtt broker port, which is used by the mqtt clients to publish or subscribe. ",
- "Example: listener 1883"
- );
-
- type Value = Port;
-}
-
///
/// Boolean whether Azure mapper should add timestamp if timestamp is not added in the incoming payload.
///
@@ -149,7 +135,7 @@ impl ConfigSetting for MqttPortSetting {
pub struct AzureMapperTimestamp;
impl ConfigSetting for AzureMapperTimestamp {
- const KEY: &'static str = "azure.mapper.timestamp";
+ const KEY: &'static str = "az.mapper.timestamp";
const DESCRIPTION: &'static str = concat!(
"Boolean whether Azure mapper should add timestamp or not. ",
@@ -158,3 +144,17 @@ impl ConfigSetting for AzureMapperTimestamp {
type Value = Flag;
}
+
+#[derive(Debug, Copy, Clone, Eq, PartialEq)]
+pub struct MqttPortSetting;
+
+impl ConfigSetting for MqttPortSetting {
+ const KEY: &'static str = "mqtt.port";
+
+ const DESCRIPTION: &'static str = concat!(
+ "Mqtt broker port, which is used by the mqtt clients to publish or subscribe. ",
+ "Example: listener 1883"
+ );
+
+ type Value = Port;
+}
diff --git a/tedge_config/src/tedge_config.rs b/tedge_config/src/tedge_config.rs
index bacc20c8..cee7d5c9 100644
--- a/tedge_config/src/tedge_config.rs
+++ b/tedge_config/src/tedge_config.rs
@@ -61,7 +61,7 @@ fn cert_error_into_config_error(key: &'static str, err: CertificateError) -> Con
impl ConfigSettingAccessor<AzureUrlSetting> for TEdgeConfig {
fn query(&self, _setting: AzureUrlSetting) -> ConfigSettingResult<ConnectUrl> {
self.data
- .azure
+ .az
.url
.clone()
.ok_or(ConfigSettingError::ConfigNotSet {
@@ -70,12 +70,12 @@ impl ConfigSettingAccessor<AzureUrlSetting> for TEdgeConfig {
}
fn update(&mut self, _setting: AzureUrlSetting, value: ConnectUrl) -> ConfigSettingResult<()> {
- self.data.azure.url = Some(value);
+ self.data.az.url = Some(value);
Ok(())
}
fn unset(&mut self, _setting: AzureUrlSetting) -> ConfigSettingResult<()> {
- self.data.azure.url = None;
+ self.data.az.url = None;
Ok(())
}
}
@@ -156,7 +156,7 @@ impl ConfigSettingAccessor<AzureRootCertPathSetting> for TEdgeConfig {
fn query(&self, _setting: AzureRootCertPathSetting) -> ConfigSettingResult<FilePath> {
Ok(self
.data
- .azure
+ .az
.root_cert_path
.clone()
.unwrap_or_else(|| self.config_defaults.default_azure_root_cert_path.clone()))
@@ -167,12 +167,12 @@ impl ConfigSettingAccessor<AzureRootCertPathSetting> for TEdgeConfig {
_setting: AzureRootCertPathSetting,
value: FilePath,
) -> ConfigSettingResult<()> {
- self.data.azure.root_cert_path = Some(value);
+ self.data.az.root_cert_path = Some(value);
Ok(())
}
fn unset(&mut self, _setting: AzureRootCertPathSetting) -> ConfigSettingResult<()> {
- self.data.azure.root_cert_path = None;
+ self.data.az.root_cert_path = None;
Ok(())
}
}
@@ -181,19 +181,19 @@ impl ConfigSettingAccessor<AzureMapperTimestamp> for TEdgeConfig {
fn query(&self, _setting: AzureMapperTimestamp) -> ConfigSettingResult<Flag> {
Ok(self
.data
- .azure
+ .az
.mapper_timestamp
.map(Flag)
.unwrap_or_else(|| Flag(true)))
}
fn update(&mut self, _setting: AzureMapperTimestamp, value: Flag) -> ConfigSettingResult<()> {
- self.data.azure.mapper_timestamp = Some(value.into());
+ self.data.az.mapper_timestamp = Some(value.into());
Ok(())
}
fn unset(&mut self, _setting: AzureMapperTimestamp) -> ConfigSettingResult<()> {
- self.data.azure.mapper_timestamp = None;
+ self.data.az.mapper_timestamp = None;
Ok(())
}
}
diff --git a/tedge_config/src/tedge_config_dto.rs b/tedge_config/src/tedge_config_dto.rs
index 0b1d9c19..f2ac7fe4 100644
--- a/tedge_config/src/tedge_config_dto.rs
+++ b/tedge_config/src/tedge_config_dto.rs
@@ -15,7 +15,7 @@ pub(crate) struct TEdgeConfigDto {
pub(crate) c8y: CumulocityConfigDto,
#[serde(default)]
- pub(crate) azure: AzureConfigDto,
+ pub(crate) az: AzureConfigDto,
#[serde(default)]
pub(crate) mqtt: MqttConfigDto,
diff --git a/tedge_config/tests/test_tedge_config.rs b/tedge_config/tests/test_tedge_config.rs
index 7c82965c..eed638e4 100644
--- a/tedge_config/tests/test_tedge_config.rs
+++ b/tedge_config/tests/test_tedge_config.rs
@@ -16,7 +16,7 @@ url = "your-tenant.cumulocity.com"
root_cert_path = "/path/to/c8y/root/cert"
connect = "true"
-[azure]
+[az]
url = "MyAzure.azure-devices.net"
root_cert_path = "/path/to/azure/root/cert"
connect = "false"
@@ -75,9 +75,10 @@ cert_path = "/path/to/cert"
url = "your-tenant.cumulocity.com"
root_cert_path = "/path/to/c8y/root/cert"
-[azure]
+[az]
url = "MyAzure.azure-devices.net"
root_cert_path = "/path/to/azure/root/cert"
+mapper_timestamp = true
[mqtt]
port = 1883
@@ -393,7 +394,7 @@ cert_path = "/path/to/cert"
url = "your-tenant.cumulocity.com"
root_cert_path = "/path/to/c8y/root/cert"
-[azure]
+[az]
url = "MyAzure.azure-devices.net"
root_cert_path = "/path/to/azure/root/cert"
@@ -471,7 +472,7 @@ cert_path = "/path/to/cert"
url = "your-tenant.cumulocity.com"
root_cert_path = "/path/to/c8y/root/cert"
-[azure]
+[az]
url = "MyAzure.azure-devices.net"
root_cert_path = "/path/to/azure/root/cert"
"#;