Skip to content

Commit 3e6d18a

Browse files
committed
Deprecate tedge_config::get_new_tedge_config and load_tedge_config
Signed-off-by: Didier Wenzek <didier.wenzek@free.fr>
1 parent 5457bb5 commit 3e6d18a

File tree

4 files changed

+16
-16
lines changed

4 files changed

+16
-16
lines changed

crates/common/tedge_config/src/lib.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,13 @@ pub use certificate::CertificateError;
1414
pub use tedge_config_macros::all_or_nothing;
1515
pub use tedge_config_macros::OptionalConfig;
1616

17-
/// loads the new tedge config from system default
18-
pub fn get_new_tedge_config() -> Result<TEdgeConfig, TEdgeConfigError> {
19-
let tedge_config_location = TEdgeConfigLocation::default();
20-
TEdgeConfigRepository::new(tedge_config_location).load()
21-
}
17+
impl TEdgeConfig {
18+
pub fn new(config_location: TEdgeConfigLocation) -> Result<Self, TEdgeConfigError> {
19+
TEdgeConfigRepository::new(config_location).load()
20+
}
2221

23-
/// loads the tedge config from a config directory
24-
pub fn load_tedge_config(config_dir: &Path) -> Result<TEdgeConfig, TEdgeConfigError> {
25-
let tedge_config_location = TEdgeConfigLocation::from_custom_root(config_dir);
26-
TEdgeConfigRepository::new(tedge_config_location).load()
22+
pub fn load(config_dir: &Path) -> Result<TEdgeConfig, TEdgeConfigError> {
23+
let config_location = TEdgeConfigLocation::from_custom_root(config_dir);
24+
TEdgeConfig::new(config_location)
25+
}
2726
}

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ use reqwest::StatusCode;
66
use reqwest::Url;
77
use std::io::prelude::*;
88
use std::path::Path;
9-
use tedge_config::get_new_tedge_config;
109
use tedge_config::HostPort;
10+
use tedge_config::TEdgeConfig;
11+
use tedge_config::TEdgeConfigLocation;
1112
use tedge_config::HTTPS_PORT;
1213

1314
#[derive(Debug, serde::Deserialize)]
@@ -50,7 +51,7 @@ impl UploadCertCmd {
5051
Err(_) => rpassword::read_password_from_tty(Some("Enter password: "))?,
5152
};
5253

53-
let config = get_new_tedge_config()?;
54+
let config = TEdgeConfig::new(TEdgeConfigLocation::default())?;
5455
let root_cert = &config.c8y.root_cert_path;
5556
let client_builder = reqwest::blocking::Client::builder();
5657
let res = match std::fs::metadata(root_cert) {

crates/core/tedge/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ fn main() -> anyhow::Result<()> {
3030
let opt = parse_multicall_if_known(&executable_name);
3131
match opt {
3232
TEdgeOptMulticall::Component(Component::TedgeMapper(opt)) => {
33-
let tedge_config = tedge_config::load_tedge_config(&opt.config_dir)?;
33+
let tedge_config = tedge_config::TEdgeConfig::load(&opt.config_dir)?;
3434
block_on_with(
3535
tedge_config.run.log_memory_interval.duration(),
3636
tedge_mapper::run(opt),
3737
)
3838
}
3939
TEdgeOptMulticall::Component(Component::TedgeAgent(opt)) => {
40-
let tedge_config = tedge_config::load_tedge_config(&opt.config_dir)?;
40+
let tedge_config = tedge_config::TEdgeConfig::load(&opt.config_dir)?;
4141
block_on_with(
4242
tedge_config.run.log_memory_interval.duration(),
4343
tedge_agent::run(opt),

crates/extensions/c8y_http_proxy/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use tedge_actors::ServerMessageBoxBuilder;
1818
use tedge_actors::ServiceProvider;
1919
use tedge_config::ConfigNotSet;
2020
use tedge_config::ReadError;
21-
use tedge_config::TEdgeConfig as NewTEdgeConfig;
21+
use tedge_config::TEdgeConfig;
2222
use tedge_http_ext::HttpRequest;
2323
use tedge_http_ext::HttpResult;
2424

@@ -40,10 +40,10 @@ pub struct C8YHttpConfig {
4040
retry_interval: Duration,
4141
}
4242

43-
impl TryFrom<&NewTEdgeConfig> for C8YHttpConfig {
43+
impl TryFrom<&TEdgeConfig> for C8YHttpConfig {
4444
type Error = C8yHttpConfigBuildError;
4545

46-
fn try_from(tedge_config: &NewTEdgeConfig) -> Result<Self, Self::Error> {
46+
fn try_from(tedge_config: &TEdgeConfig) -> Result<Self, Self::Error> {
4747
let c8y_host = tedge_config.c8y.http.or_config_not_set()?.to_string();
4848
let device_id = tedge_config.device.id.try_read(tedge_config)?.to_string();
4949
let tmp_dir = tedge_config.tmp.path.as_std_path().to_path_buf();

0 commit comments

Comments
 (0)