File tree Expand file tree Collapse file tree 4 files changed +16
-16
lines changed
extensions/c8y_http_proxy/src Expand file tree Collapse file tree 4 files changed +16
-16
lines changed Original file line number Diff line number Diff line change @@ -14,14 +14,13 @@ pub use certificate::CertificateError;
14
14
pub use tedge_config_macros:: all_or_nothing;
15
15
pub use tedge_config_macros:: OptionalConfig ;
16
16
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
+ }
22
21
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
+ }
27
26
}
Original file line number Diff line number Diff line change @@ -6,8 +6,9 @@ use reqwest::StatusCode;
6
6
use reqwest:: Url ;
7
7
use std:: io:: prelude:: * ;
8
8
use std:: path:: Path ;
9
- use tedge_config:: get_new_tedge_config;
10
9
use tedge_config:: HostPort ;
10
+ use tedge_config:: TEdgeConfig ;
11
+ use tedge_config:: TEdgeConfigLocation ;
11
12
use tedge_config:: HTTPS_PORT ;
12
13
13
14
#[ derive( Debug , serde:: Deserialize ) ]
@@ -50,7 +51,7 @@ impl UploadCertCmd {
50
51
Err ( _) => rpassword:: read_password_from_tty ( Some ( "Enter password: " ) ) ?,
51
52
} ;
52
53
53
- let config = get_new_tedge_config ( ) ?;
54
+ let config = TEdgeConfig :: new ( TEdgeConfigLocation :: default ( ) ) ?;
54
55
let root_cert = & config. c8y . root_cert_path ;
55
56
let client_builder = reqwest:: blocking:: Client :: builder ( ) ;
56
57
let res = match std:: fs:: metadata ( root_cert) {
Original file line number Diff line number Diff line change @@ -30,14 +30,14 @@ fn main() -> anyhow::Result<()> {
30
30
let opt = parse_multicall_if_known ( & executable_name) ;
31
31
match opt {
32
32
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 ) ?;
34
34
block_on_with (
35
35
tedge_config. run . log_memory_interval . duration ( ) ,
36
36
tedge_mapper:: run ( opt) ,
37
37
)
38
38
}
39
39
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 ) ?;
41
41
block_on_with (
42
42
tedge_config. run . log_memory_interval . duration ( ) ,
43
43
tedge_agent:: run ( opt) ,
Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ use tedge_actors::ServerMessageBoxBuilder;
18
18
use tedge_actors:: ServiceProvider ;
19
19
use tedge_config:: ConfigNotSet ;
20
20
use tedge_config:: ReadError ;
21
- use tedge_config:: TEdgeConfig as NewTEdgeConfig ;
21
+ use tedge_config:: TEdgeConfig ;
22
22
use tedge_http_ext:: HttpRequest ;
23
23
use tedge_http_ext:: HttpResult ;
24
24
@@ -40,10 +40,10 @@ pub struct C8YHttpConfig {
40
40
retry_interval : Duration ,
41
41
}
42
42
43
- impl TryFrom < & NewTEdgeConfig > for C8YHttpConfig {
43
+ impl TryFrom < & TEdgeConfig > for C8YHttpConfig {
44
44
type Error = C8yHttpConfigBuildError ;
45
45
46
- fn try_from ( tedge_config : & NewTEdgeConfig ) -> Result < Self , Self :: Error > {
46
+ fn try_from ( tedge_config : & TEdgeConfig ) -> Result < Self , Self :: Error > {
47
47
let c8y_host = tedge_config. c8y . http . or_config_not_set ( ) ?. to_string ( ) ;
48
48
let device_id = tedge_config. device . id . try_read ( tedge_config) ?. to_string ( ) ;
49
49
let tmp_dir = tedge_config. tmp . path . as_std_path ( ) . to_path_buf ( ) ;
You can’t perform that action at this time.
0 commit comments