Skip to content

Commit c2093ec

Browse files
authored
Merge pull request #3470 from Bravo555/refactor/tedge-config-visibility
refactor: Reduce number of items exported at the top crate level by `tedge_config`
2 parents bfda95e + a44c828 commit c2093ec

File tree

70 files changed

+169
-158
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+169
-158
lines changed

crates/common/tedge_config/src/lib.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
mod sudo;
2-
pub mod tedge_toml;
32
pub use sudo::SudoCommandBuilder;
43
pub mod cli;
54
mod system_toml;
5+
pub use system_toml::*;
6+
7+
pub mod tedge_toml;
8+
pub use tedge_toml::error::*;
9+
pub use tedge_toml::models;
10+
pub use tedge_toml::tedge_config::TEdgeConfig;
11+
pub use tedge_toml::tedge_config::TEdgeConfigDto;
12+
pub use tedge_toml::tedge_config::TEdgeConfigReader;
13+
pub use tedge_toml::tedge_config_location::*;
614

7-
pub use self::system_toml::*;
8-
pub use self::tedge_toml::error::*;
9-
pub use self::tedge_toml::models::*;
10-
pub use self::tedge_toml::tedge_config::*;
11-
pub use self::tedge_toml::tedge_config_location::*;
1215
pub use camino::Utf8Path as Path;
1316
pub use camino::Utf8PathBuf as PathBuf;
1417
pub use certificate::CertificateError;

crates/common/tedge_config/src/tedge_toml/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ pub enum ConfigSettingError {
7070
Other { msg: &'static str },
7171

7272
#[error(transparent)]
73-
Write(#[from] crate::WriteError),
73+
Write(#[from] super::WriteError),
7474
}
7575

7676
impl TEdgeConfigError {

crates/common/tedge_config/src/tedge_toml/figment.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -214,11 +214,11 @@ impl TEdgeEnv {
214214
Uncased::new(
215215
tracing::subscriber::with_default(
216216
tracing::subscriber::NoSubscriber::default(),
217-
|| lowercase_name.parse::<crate::WritableKey>(),
217+
|| lowercase_name.parse::<crate::tedge_toml::WritableKey>(),
218218
)
219219
.map(|key| key.to_string())
220220
.map_err(|err| {
221-
let is_read_only_key = matches!(err, crate::ParseKeyError::ReadOnly(_));
221+
let is_read_only_key = matches!(err, crate::tedge_toml::ParseKeyError::ReadOnly(_));
222222
if is_read_only_key && !WARNINGS.lock().unwrap().insert(lowercase_name.clone()) {
223223
tracing::error!(
224224
"Failed to configure tedge with environment variable `TEDGE_{name}`: {}",
@@ -236,6 +236,8 @@ impl TEdgeEnv {
236236
mod tests {
237237
use std::path::PathBuf;
238238

239+
use crate::tedge_toml::AppendRemoveItem;
240+
use crate::tedge_toml::ReadError;
239241
use serde::Deserialize;
240242
use tedge_config_macros::define_tedge_config;
241243

@@ -381,8 +383,6 @@ mod tests {
381383

382384
#[test]
383385
fn environment_variables_can_override_profiled_configurations() {
384-
use crate::AppendRemoveItem;
385-
use crate::ReadError;
386386
use tedge_config_macros::*;
387387

388388
define_tedge_config!(
@@ -417,8 +417,6 @@ mod tests {
417417

418418
#[test]
419419
fn environment_variable_profile_warnings_use_key_with_correct_format() {
420-
use crate::AppendRemoveItem;
421-
use crate::ReadError;
422420
use tedge_config_macros::*;
423421

424422
define_tedge_config!(
@@ -445,8 +443,6 @@ mod tests {
445443

446444
#[test]
447445
fn toml_profile_warnings_use_key_with_correct_format() {
448-
use crate::AppendRemoveItem;
449-
use crate::ReadError;
450446
use tedge_config_macros::*;
451447

452448
define_tedge_config!(

crates/common/tedge_config/src/tedge_toml/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@ pub mod error;
22
mod figment;
33
pub mod models;
44
pub mod tedge_config;
5+
pub use tedge_config::*;
6+
57
pub mod tedge_config_location;

crates/common/tedge_config/src/tedge_toml/models/host_port.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use crate::ConnectUrl;
2-
use crate::Port;
1+
use super::ConnectUrl;
2+
use super::Port;
33
use serde::Deserialize;
44
use serde::Serialize;
55
use std::fmt;
@@ -19,7 +19,7 @@ use url::Host;
1919
/// # Examples
2020
///
2121
/// ```
22-
/// # use tedge_config::{HostPort, Port, HTTPS_PORT};
22+
/// # use tedge_config::models::{HostPort, Port, HTTPS_PORT};
2323
///
2424
/// // use a fallback port if not present in string
2525
/// let http = HostPort::<HTTPS_PORT>::try_from("my-tenant.cumulocity.com".to_string()).unwrap();
@@ -142,8 +142,9 @@ pub enum ParseHostPortError {
142142
#[cfg(test)]
143143
mod tests {
144144
use super::*;
145-
use crate::HTTPS_PORT;
146-
use crate::MQTT_TLS_PORT;
145+
146+
use super::super::HTTPS_PORT;
147+
use super::super::MQTT_TLS_PORT;
147148
use test_case::test_case;
148149

149150
#[test_case(HostPort::<HTTPS_PORT>::try_from("test.com").unwrap(), "test.com:443")]

crates/common/tedge_config/src/tedge_toml/models/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ pub use self::port::*;
3333
pub use self::seconds::*;
3434
pub use self::templates_set::*;
3535
pub use tedge_utils::timestamp;
36+
pub use tedge_utils::timestamp::TimeFormat;
3637
pub use topic_prefix::TopicPrefix;
3738

3839
#[derive(

crates/common/tedge_config/src/tedge_toml/tedge_config.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,21 @@ use version::TEdgeTomlVersion;
44
mod append_remove;
55
pub use append_remove::AppendRemoveItem;
66

7+
use super::models::auth_method::AuthMethod;
78
use super::models::timestamp::TimeFormat;
8-
use crate::auth_method::AuthMethod;
9-
use crate::AptConfig;
10-
use crate::AutoFlag;
11-
use crate::AutoLogUpload;
12-
use crate::ConnectUrl;
13-
use crate::HostPort;
14-
use crate::MqttPayloadLimit;
15-
use crate::SecondsOrHumanTime;
16-
use crate::SoftwareManagementApiFlag;
17-
use crate::TEdgeConfigLocation;
18-
use crate::TemplatesSet;
19-
use crate::TopicPrefix;
20-
use crate::HTTPS_PORT;
21-
use crate::MQTT_TLS_PORT;
9+
use super::models::AptConfig;
10+
use super::models::AutoFlag;
11+
use super::models::AutoLogUpload;
12+
use super::models::ConnectUrl;
13+
use super::models::HostPort;
14+
use super::models::MqttPayloadLimit;
15+
use super::models::SecondsOrHumanTime;
16+
use super::models::SoftwareManagementApiFlag;
17+
use super::models::TemplatesSet;
18+
use super::models::TopicPrefix;
19+
use super::models::HTTPS_PORT;
20+
use super::models::MQTT_TLS_PORT;
21+
use super::tedge_config_location::TEdgeConfigLocation;
2222
use anyhow::anyhow;
2323
use anyhow::Context;
2424
use camino::Utf8Path;

crates/common/tedge_config/src/tedge_toml/tedge_config_location.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ impl TEdgeConfigLocation {
193193
mod tests {
194194
use tedge_test_utils::fs::TempTedgeDir;
195195

196-
use crate::Cloud;
196+
use crate::tedge_toml::Cloud;
197197
use crate::TEdgeConfigReader;
198198

199199
use super::*;

crates/core/c8y_api/src/http_proxy.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ use reqwest::header::InvalidHeaderValue;
1414
use reqwest::Url;
1515
use std::path::PathBuf;
1616
use std::time::Duration;
17-
use tedge_config::auth_method::AuthType;
17+
use tedge_config::models::auth_method::AuthType;
18+
use tedge_config::models::TopicPrefix;
19+
use tedge_config::tedge_toml::ConfigNotSet;
20+
use tedge_config::tedge_toml::MultiError;
21+
use tedge_config::tedge_toml::ReadError;
1822
use tedge_config::CertificateError;
19-
use tedge_config::ConfigNotSet;
20-
use tedge_config::MultiError;
21-
use tedge_config::ReadError;
2223
use tedge_config::TEdgeConfig;
23-
use tedge_config::TopicPrefix;
2424
use tracing::debug;
2525
use tracing::error;
2626
use tracing::info;

crates/core/c8y_api/src/json_c8y_deserializer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use tedge_api::mqtt_topics::EntityTopicId;
1212
use tedge_api::SoftwareModule;
1313
use tedge_api::SoftwareModuleUpdate;
1414
use tedge_api::SoftwareUpdateCommand;
15-
use tedge_config::TopicPrefix;
15+
use tedge_config::models::TopicPrefix;
1616
use time::OffsetDateTime;
1717

1818
pub struct C8yDeviceControlTopic;

0 commit comments

Comments
 (0)