Skip to content

Commit b3f3810

Browse files
committed
Don't reexport inner tedge_config::*
tedge_config! macro creates a lot of structs that clutter item list when reexported. Instead reexport only top-level struct as that what's most commonly used. Signed-off-by: Marcel Guzik <[email protected]>
1 parent 9136516 commit b3f3810

File tree

48 files changed

+89
-83
lines changed

Some content is hidden

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

48 files changed

+89
-83
lines changed

crates/common/tedge_config/src/lib.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@ pub use self::system_toml::*;
66

77
pub mod tedge_toml;
88
pub use self::tedge_toml::error::*;
9-
pub use self::tedge_toml::tedge_config::*;
109
pub use self::tedge_toml::tedge_config_location::*;
1110
pub use tedge_toml::models;
11+
pub use tedge_toml::tedge_config::TEdgeConfig;
12+
pub use tedge_toml::tedge_config::TEdgeConfigDto;
13+
pub use tedge_toml::tedge_config::TEdgeConfigReader;
1214

1315
pub use camino::Utf8Path as Path;
1416
pub use camino::Utf8PathBuf as PathBuf;

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

+1-1
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] crate::tedge_toml::tedge_config::WriteError),
7474
}
7575

7676
impl TEdgeConfigError {

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

+4-8
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

+2
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/tedge_config_location.rs

+1-1
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

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ use std::path::PathBuf;
1616
use std::time::Duration;
1717
use tedge_config::models::auth_method::AuthType;
1818
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;
1922
use tedge_config::CertificateError;
20-
use tedge_config::ConfigNotSet;
21-
use tedge_config::MultiError;
22-
use tedge_config::ReadError;
2323
use tedge_config::TEdgeConfig;
2424
use tracing::debug;
2525
use tracing::error;

crates/core/tedge/src/bridge/aws.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use tedge_api::mqtt_topics::MqttSchema;
99
use tedge_config::models::HostPort;
1010
use tedge_config::models::TopicPrefix;
1111
use tedge_config::models::MQTT_TLS_PORT;
12-
use tedge_config::ProfileName;
12+
use tedge_config::tedge_toml::ProfileName;
1313

1414
#[derive(Debug)]
1515
pub struct BridgeConfigAwsParams {

crates/core/tedge/src/bridge/azure.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use tedge_api::mqtt_topics::MqttSchema;
99
use tedge_config::models::HostPort;
1010
use tedge_config::models::TopicPrefix;
1111
use tedge_config::models::MQTT_TLS_PORT;
12-
use tedge_config::ProfileName;
12+
use tedge_config::tedge_toml::ProfileName;
1313

1414
#[derive(Debug)]
1515
pub struct BridgeConfigAzureParams {

crates/core/tedge/src/bridge/c8y.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use tedge_config::models::HostPort;
1313
use tedge_config::models::TemplatesSet;
1414
use tedge_config::models::TopicPrefix;
1515
use tedge_config::models::MQTT_TLS_PORT;
16-
use tedge_config::ProfileName;
16+
use tedge_config::tedge_toml::ProfileName;
1717
use which::which;
1818

1919
#[derive(Debug)]

crates/core/tedge/src/cli/certificate/cli.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ use super::upload::*;
88
use anyhow::anyhow;
99
use camino::Utf8PathBuf;
1010
use clap::ValueHint;
11-
use tedge_config::OptionalConfigError;
12-
use tedge_config::ProfileName;
11+
use tedge_config::tedge_toml::OptionalConfigError;
12+
use tedge_config::tedge_toml::ProfileName;
1313
use tedge_config::TEdgeConfig;
1414

1515
use crate::cli::common::Cloud;

crates/core/tedge/src/cli/common.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use clap_complete::CompletionCandidate;
55
use std::borrow::Cow;
66
use std::fmt;
77
use tedge_config::get_config_dir;
8-
use tedge_config::ProfileName;
8+
use tedge_config::tedge_toml::ProfileName;
99
use tedge_config::TEdgeConfigLocation;
1010

1111
#[derive(clap::Subcommand, Debug, Clone, PartialEq, Eq)]
@@ -103,12 +103,12 @@ impl fmt::Display for MaybeBorrowedCloud<'_> {
103103
}
104104
}
105105

106-
impl<'a> From<&'a MaybeBorrowedCloud<'a>> for tedge_config::Cloud<'a> {
107-
fn from(value: &'a MaybeBorrowedCloud<'a>) -> tedge_config::Cloud<'a> {
106+
impl<'a> From<&'a MaybeBorrowedCloud<'a>> for tedge_config::tedge_toml::Cloud<'a> {
107+
fn from(value: &'a MaybeBorrowedCloud<'a>) -> tedge_config::tedge_toml::Cloud<'a> {
108108
match value {
109-
MaybeBorrowedCloud::C8y(p) => tedge_config::Cloud::C8y(p.as_deref()),
110-
MaybeBorrowedCloud::Azure(p) => tedge_config::Cloud::Az(p.as_deref()),
111-
MaybeBorrowedCloud::Aws(p) => tedge_config::Cloud::Aws(p.as_deref()),
109+
MaybeBorrowedCloud::C8y(p) => tedge_config::tedge_toml::Cloud::C8y(p.as_deref()),
110+
MaybeBorrowedCloud::Azure(p) => tedge_config::tedge_toml::Cloud::Az(p.as_deref()),
111+
MaybeBorrowedCloud::Aws(p) => tedge_config::tedge_toml::Cloud::Aws(p.as_deref()),
112112
}
113113
}
114114
}

crates/core/tedge/src/cli/config/cli.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ use crate::cli::config::commands::*;
33
use crate::command::*;
44
use crate::ConfigError;
55
use clap_complete::ArgValueCandidates;
6-
use tedge_config::ProfileName;
7-
use tedge_config::ReadableKey;
8-
use tedge_config::WritableKey;
6+
use tedge_config::tedge_toml::ProfileName;
7+
use tedge_config::tedge_toml::ReadableKey;
8+
use tedge_config::tedge_toml::WritableKey;
99

1010
#[derive(clap::Subcommand, Debug)]
1111
pub enum ConfigCmd {

crates/core/tedge/src/cli/config/commands/add.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::command::Command;
22
use crate::log::MaybeFancy;
3+
use tedge_config::tedge_toml::WritableKey;
34
use tedge_config::TEdgeConfigLocation;
4-
use tedge_config::WritableKey;
55

66
pub struct AddConfigCommand {
77
pub key: WritableKey,

crates/core/tedge/src/cli/config/commands/get.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use tedge_config::ReadableKey;
1+
use tedge_config::tedge_toml::ReadableKey;
22

33
use crate::command::Command;
44
use crate::log::MaybeFancy;
@@ -18,11 +18,11 @@ impl Command for GetConfigCommand {
1818
Ok(value) => {
1919
println!("{}", value);
2020
}
21-
Err(tedge_config::ReadError::ConfigNotSet { .. }) => {
21+
Err(tedge_config::tedge_toml::ReadError::ConfigNotSet { .. }) => {
2222
eprintln!("The provided config key: '{}' is not set", self.key);
2323
std::process::exit(1)
2424
}
25-
Err(tedge_config::ReadError::ReadOnlyNotFound { message, key }) => {
25+
Err(tedge_config::tedge_toml::ReadError::ReadOnlyNotFound { message, key }) => {
2626
eprintln!("The provided config key: '{key}' is not configured: {message}",);
2727
std::process::exit(1)
2828
}

crates/core/tedge/src/cli/config/commands/list.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ use crate::log::MaybeFancy;
33
use pad::PadStr;
44
use std::io::stdout;
55
use std::io::IsTerminal;
6+
use tedge_config::tedge_toml::READABLE_KEYS;
67
use tedge_config::TEdgeConfig;
7-
use tedge_config::READABLE_KEYS;
88
use yansi::Paint;
99

1010
pub struct ListConfigCommand {

crates/core/tedge/src/cli/config/commands/remove.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::command::Command;
22
use crate::log::MaybeFancy;
3+
use tedge_config::tedge_toml::WritableKey;
34
use tedge_config::TEdgeConfigLocation;
4-
use tedge_config::WritableKey;
55

66
pub struct RemoveConfigCommand {
77
pub key: WritableKey,

crates/core/tedge/src/cli/config/commands/set.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::command::Command;
22
use crate::log::MaybeFancy;
3+
use tedge_config::tedge_toml::WritableKey;
34
use tedge_config::TEdgeConfigLocation;
4-
use tedge_config::WritableKey;
55

66
pub struct SetConfigCommand {
77
pub key: WritableKey,

crates/core/tedge/src/cli/config/commands/unset.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::command::Command;
22
use crate::log::MaybeFancy;
3+
use tedge_config::tedge_toml::WritableKey;
34
use tedge_config::TEdgeConfigLocation;
4-
use tedge_config::WritableKey;
55

66
pub struct UnsetConfigCommand {
77
pub key: WritableKey,

crates/core/tedge/src/cli/connect/c8y_direct_connection.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use rumqttc::Packet;
1717
use rumqttc::QoS;
1818
use rumqttc::TlsError;
1919
use rumqttc::Transport;
20-
use tedge_config::MqttAuthConfigCloudBroker;
20+
use tedge_config::tedge_toml::MqttAuthConfigCloudBroker;
2121

2222
const CONNECTION_ERROR_CONTEXT: &str = "Connection error while creating device in Cumulocity";
2323

crates/core/tedge/src/cli/connect/command.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,17 @@ use tedge_api::mqtt_topics::EntityTopicId;
4343
use tedge_api::mqtt_topics::MqttSchema;
4444
use tedge_api::mqtt_topics::TopicIdError;
4545
use tedge_api::service_health_topic;
46+
use tedge_config;
4647
use tedge_config::models::auth_method::AuthType;
4748
use tedge_config::models::HostPort;
4849
use tedge_config::models::TopicPrefix;
50+
use tedge_config::tedge_toml::MultiError;
51+
use tedge_config::tedge_toml::ProfileName;
52+
use tedge_config::tedge_toml::ReadableKey;
53+
use tedge_config::tedge_toml::TEdgeConfigReaderMqtt;
4954
use tedge_config::TEdgeConfig;
50-
use tedge_config::*;
55+
use tedge_config::TEdgeConfigError;
56+
use tedge_config::TEdgeConfigLocation;
5157
use tedge_utils::paths::create_directories;
5258
use tedge_utils::paths::ok_if_not_found;
5359
use tedge_utils::paths::DraftFile;

crates/core/tedge/src/cli/connect/error.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ pub enum ConnectError {
5656
CertificateError(#[from] certificate::CertificateError),
5757

5858
#[error(transparent)]
59-
MultiError(#[from] tedge_config::MultiError),
59+
MultiError(#[from] tedge_config::tedge_toml::MultiError),
6060

6161
#[error(transparent)]
6262
Anyhow(#[from] anyhow::Error),

crates/core/tedge/src/cli/http/cli.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ use clap::Args;
1212
use reqwest::blocking;
1313
use reqwest::Identity;
1414
use std::fs::File;
15+
use tedge_config::tedge_toml::ProfileName;
1516
use tedge_config::OptionalConfig;
16-
use tedge_config::ProfileName;
1717

1818
#[derive(clap::Subcommand, Debug)]
1919
pub enum TEdgeHttpCli {

crates/core/tedge/src/cli/log.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use crate::system_services::SystemServiceManager;
1111
use camino::Utf8Path;
1212
use tedge_config::models::auth_method::AuthMethod;
1313
use tedge_config::models::auth_method::AuthType;
14-
use tedge_config::MultiError;
14+
use tedge_config::tedge_toml::MultiError;
1515
use yansi::Paint as _;
1616

1717
use crate::bridge::BridgeConfig;

crates/core/tedge/src/cli/mqtt/publish.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use rumqttc::Packet;
1515
use rumqttc::QoS::AtLeastOnce;
1616
use rumqttc::QoS::AtMostOnce;
1717
use rumqttc::QoS::ExactlyOnce;
18-
use tedge_config::MqttAuthClientConfig;
18+
use tedge_config::tedge_toml::MqttAuthClientConfig;
1919

2020
const DEFAULT_QUEUE_CAPACITY: usize = 10;
2121
use super::MAX_PACKET_SIZE;

crates/core/tedge/src/cli/mqtt/subscribe.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use rumqttc::Packet;
1414
use rumqttc::QoS;
1515
use std::sync::atomic::Ordering;
1616
use std::time::Duration;
17-
use tedge_config::MqttAuthClientConfig;
17+
use tedge_config::tedge_toml::MqttAuthClientConfig;
1818

1919
const DEFAULT_QUEUE_CAPACITY: usize = 10;
2020
use super::MAX_PACKET_SIZE;

crates/core/tedge/src/cli/upload/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::ConfigError;
55
use c8y_api::http_proxy::C8yEndPoint;
66
use std::collections::HashMap;
77
use std::path::PathBuf;
8-
use tedge_config::ProfileName;
8+
use tedge_config::tedge_toml::ProfileName;
99

1010
mod c8y;
1111

crates/core/tedge/src/command.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ use crate::log::MaybeFancy;
3333
/// ```
3434
/// use tedge::command::Command;
3535
/// use tedge_config::TEdgeConfig;
36-
/// use tedge_config::ReadError;
37-
/// use tedge_config::ReadableKey;
36+
/// use tedge_config::tedge_toml::ReadError;
37+
/// use tedge_config::tedge_toml::ReadableKey;
3838
/// use tedge::log::MaybeFancy;
3939
///
4040
/// struct GetConfigKey {
@@ -84,7 +84,7 @@ pub trait Command {
8484
/// The `BuildCommand::build_command()` method has to return a box around a new command.
8585
///
8686
/// ```
87-
/// use tedge_config::ReadableKey;
87+
/// use tedge_config::tedge_toml::ReadableKey;
8888
/// use tedge_config::TEdgeConfig;
8989
/// use tedge::cli::config::GetConfigCommand;
9090
/// use tedge::ConfigError;
@@ -117,7 +117,7 @@ pub trait Command {
117117
/// use tedge::command::*;
118118
/// use tedge::cli::config::*;
119119
/// use tedge::ConfigError;
120-
/// use tedge_config::*;
120+
/// use tedge_config::tedge_toml::tedge_config::*;
121121
///
122122
/// #[derive(clap::Parser, Debug)]
123123
/// enum ConfigCmd {

crates/core/tedge/src/error.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use tedge_config::MultiError;
1+
use tedge_config::tedge_toml::MultiError;
22

33
#[derive(thiserror::Error, Debug)]
44
#[allow(clippy::enum_variant_names)]
@@ -31,10 +31,10 @@ pub enum TEdgeError {
3131
FromSystemToml(#[from] tedge_config::SystemTomlError),
3232

3333
#[error(transparent)]
34-
FromTEdgeConfigRead(#[from] tedge_config::ReadError),
34+
FromTEdgeConfigRead(#[from] tedge_config::tedge_toml::ReadError),
3535

3636
#[error(transparent)]
37-
FromConfigNotSet(#[from] tedge_config::ConfigNotSet),
37+
FromConfigNotSet(#[from] tedge_config::tedge_toml::ConfigNotSet),
3838

3939
#[error(transparent)]
4040
FromMultiError(#[from] MultiError),

crates/core/tedge/src/system_services/services.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use std::fmt;
2-
use tedge_config::ProfileName;
2+
use tedge_config::tedge_toml::ProfileName;
33

44
/// An enumeration of all supported system services.
55
#[derive(Debug, Copy, Clone, strum_macros::IntoStaticStr)]

crates/core/tedge_agent/src/agent.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ use tedge_api::mqtt_topics::MqttSchema;
4646
use tedge_api::mqtt_topics::Service;
4747
use tedge_api::path::DataDir;
4848
use tedge_api::EntityStore;
49-
use tedge_config::TEdgeConfigReaderService;
49+
use tedge_config::tedge_toml::TEdgeConfigReaderService;
5050
use tedge_config_manager::ConfigManagerBuilder;
5151
use tedge_config_manager::ConfigManagerConfig;
5252
use tedge_config_manager::ConfigManagerOptions;

0 commit comments

Comments
 (0)