@@ -8,15 +8,13 @@ use serde::{Deserialize, Serialize};
88
99use crate :: adapters:: ssh:: SshCredentials ;
1010use crate :: domain:: provider:: { Provider , ProviderConfig } ;
11- use crate :: domain:: tracker:: {
12- DatabaseConfig , HttpApiConfig , HttpTrackerConfig , TrackerConfig , TrackerCoreConfig ,
13- UdpTrackerConfig ,
14- } ;
11+ use crate :: domain:: tracker:: TrackerConfig ;
1512use crate :: domain:: { EnvironmentName , InstanceName } ;
1613
1714use super :: errors:: CreateConfigError ;
1815use super :: provider:: { HetznerProviderSection , LxdProviderSection , ProviderSection } ;
1916use super :: ssh_credentials_config:: SshCredentialsConfig ;
17+ use super :: tracker:: TrackerSection ;
2018
2119/// Configuration for creating a deployment environment
2220///
@@ -86,7 +84,10 @@ pub struct EnvironmentCreationConfig {
8684 pub provider : ProviderSection ,
8785
8886 /// Tracker deployment configuration
89- pub tracker : TrackerConfig ,
87+ ///
88+ /// Uses `TrackerSection` for JSON parsing with String primitives.
89+ /// Converted to domain `TrackerConfig` via `to_environment_params()`.
90+ pub tracker : TrackerSection ,
9091}
9192
9293/// Environment-specific configuration section
@@ -125,7 +126,7 @@ impl EnvironmentCreationConfig {
125126 /// EnvironmentCreationConfig, EnvironmentSection, SshCredentialsConfig,
126127 /// ProviderSection, LxdProviderSection
127128 /// };
128- /// use torrust_tracker_deployer_lib::domain:: tracker::TrackerConfig ;
129+ /// use torrust_tracker_deployer_lib::application::command_handlers::create::config:: tracker::TrackerSection ;
129130 ///
130131 /// let config = EnvironmentCreationConfig::new(
131132 /// EnvironmentSection {
@@ -141,15 +142,15 @@ impl EnvironmentCreationConfig {
141142 /// ProviderSection::Lxd(LxdProviderSection {
142143 /// profile_name: "torrust-profile-dev".to_string(),
143144 /// }),
144- /// TrackerConfig ::default(),
145+ /// TrackerSection ::default(),
145146 /// );
146147 /// ```
147148 #[ must_use]
148149 pub fn new (
149150 environment : EnvironmentSection ,
150151 ssh_credentials : SshCredentialsConfig ,
151152 provider : ProviderSection ,
152- tracker : TrackerConfig ,
153+ tracker : TrackerSection ,
153154 ) -> Self {
154155 Self {
155156 environment,
@@ -199,8 +200,8 @@ impl EnvironmentCreationConfig {
199200 /// EnvironmentCreationConfig, EnvironmentSection, SshCredentialsConfig,
200201 /// ProviderSection, LxdProviderSection
201202 /// };
203+ /// use torrust_tracker_deployer_lib::application::command_handlers::create::config::tracker::TrackerSection;
202204 /// use torrust_tracker_deployer_lib::domain::Environment;
203- /// use torrust_tracker_deployer_lib::domain::tracker::TrackerConfig;
204205 ///
205206 /// let config = EnvironmentCreationConfig::new(
206207 /// EnvironmentSection {
@@ -216,7 +217,7 @@ impl EnvironmentCreationConfig {
216217 /// ProviderSection::Lxd(LxdProviderSection {
217218 /// profile_name: "torrust-profile-dev".to_string(),
218219 /// }),
219- /// TrackerConfig ::default(),
220+ /// TrackerSection ::default(),
220221 /// );
221222 ///
222223 /// let (name, instance_name, provider_config, credentials, port, tracker) = config.to_environment_params()?;
@@ -261,8 +262,8 @@ impl EnvironmentCreationConfig {
261262 // Convert SSH credentials config to domain type
262263 let ssh_credentials = self . ssh_credentials . to_ssh_credentials ( ) ?;
263264
264- // Get tracker config
265- let tracker_config = self . tracker ;
265+ // Convert TrackerSection (DTO) to domain TrackerConfig (validates bind addresses, etc.)
266+ let tracker_config = self . tracker . to_tracker_config ( ) ? ;
266267
267268 Ok ( (
268269 environment_name,
@@ -338,21 +339,21 @@ impl EnvironmentCreationConfig {
338339 port : 22 , // default value
339340 } ,
340341 provider : provider_section,
341- tracker : TrackerConfig {
342- core : TrackerCoreConfig {
343- database : DatabaseConfig :: Sqlite {
342+ tracker : TrackerSection {
343+ core : super :: tracker :: TrackerCoreSection {
344+ database : super :: tracker :: DatabaseSection :: Sqlite {
344345 database_name : "tracker.db" . to_string ( ) ,
345346 } ,
346347 private : false ,
347348 } ,
348- udp_trackers : vec ! [ UdpTrackerConfig {
349- bind_address: "0.0.0.0:6969" . parse ( ) . unwrap ( ) ,
349+ udp_trackers : vec ! [ super :: tracker :: UdpTrackerSection {
350+ bind_address: "0.0.0.0:6969" . to_string ( ) ,
350351 } ] ,
351- http_trackers : vec ! [ HttpTrackerConfig {
352- bind_address: "0.0.0.0:7070" . parse ( ) . unwrap ( ) ,
352+ http_trackers : vec ! [ super :: tracker :: HttpTrackerSection {
353+ bind_address: "0.0.0.0:7070" . to_string ( ) ,
353354 } ] ,
354- http_api : HttpApiConfig {
355- bind_address : "0.0.0.0:1212" . parse ( ) . unwrap ( ) ,
355+ http_api : super :: tracker :: HttpApiSection {
356+ bind_address : "0.0.0.0:1212" . to_string ( ) ,
356357 admin_token : "MyAccessToken" . to_string ( ) ,
357358 } ,
358359 } ,
@@ -434,6 +435,7 @@ impl EnvironmentCreationConfig {
434435mod tests {
435436 use super :: * ;
436437 use crate :: application:: command_handlers:: create:: config:: provider:: LxdProviderSection ;
438+ use crate :: application:: command_handlers:: create:: config:: tracker:: TrackerSection ;
437439 use crate :: domain:: provider:: Provider ;
438440
439441 /// Helper to create a default LXD provider section for tests
@@ -457,7 +459,7 @@ mod tests {
457459 22 ,
458460 ) ,
459461 default_lxd_provider ( "torrust-profile-dev" ) ,
460- TrackerConfig :: default ( ) ,
462+ TrackerSection :: default ( ) ,
461463 ) ;
462464
463465 assert_eq ! ( config. environment. name, "dev" ) ;
@@ -598,7 +600,7 @@ mod tests {
598600 22 ,
599601 ) ,
600602 default_lxd_provider ( "torrust-profile-staging" ) ,
601- TrackerConfig :: default ( ) ,
603+ TrackerSection :: default ( ) ,
602604 ) ;
603605
604606 let json = serde_json:: to_string ( & config) . unwrap ( ) ;
@@ -621,7 +623,7 @@ mod tests {
621623 22 ,
622624 ) ,
623625 default_lxd_provider ( "torrust-profile-dev" ) ,
624- TrackerConfig :: default ( ) ,
626+ TrackerSection :: default ( ) ,
625627 ) ;
626628
627629 let result = config. to_environment_params ( ) ;
@@ -650,7 +652,7 @@ mod tests {
650652 22 ,
651653 ) ,
652654 default_lxd_provider ( "torrust-profile-prod" ) ,
653- TrackerConfig :: default ( ) ,
655+ TrackerSection :: default ( ) ,
654656 ) ;
655657
656658 let result = config. to_environment_params ( ) ;
@@ -677,7 +679,7 @@ mod tests {
677679 22 ,
678680 ) ,
679681 default_lxd_provider ( "torrust-profile" ) ,
680- TrackerConfig :: default ( ) ,
682+ TrackerSection :: default ( ) ,
681683 ) ;
682684
683685 let result = config. to_environment_params ( ) ;
@@ -705,7 +707,7 @@ mod tests {
705707 22 ,
706708 ) ,
707709 default_lxd_provider ( "torrust-profile" ) ,
708- TrackerConfig :: default ( ) ,
710+ TrackerSection :: default ( ) ,
709711 ) ;
710712
711713 let result = config. to_environment_params ( ) ;
@@ -736,7 +738,7 @@ mod tests {
736738 ProviderSection :: Lxd ( LxdProviderSection {
737739 profile_name : "invalid-" . to_string ( ) , // ends with dash - invalid
738740 } ) ,
739- TrackerConfig :: default ( ) ,
741+ TrackerSection :: default ( ) ,
740742 ) ;
741743
742744 let result = config. to_environment_params ( ) ;
@@ -764,7 +766,7 @@ mod tests {
764766 22 ,
765767 ) ,
766768 default_lxd_provider ( "torrust-profile-dev" ) ,
767- TrackerConfig :: default ( ) ,
769+ TrackerSection :: default ( ) ,
768770 ) ;
769771
770772 let result = config. to_environment_params ( ) ;
@@ -792,7 +794,7 @@ mod tests {
792794 22 ,
793795 ) ,
794796 default_lxd_provider ( "torrust-profile-dev" ) ,
795- TrackerConfig :: default ( ) ,
797+ TrackerSection :: default ( ) ,
796798 ) ;
797799
798800 let result = config. to_environment_params ( ) ;
@@ -820,7 +822,7 @@ mod tests {
820822 22 ,
821823 ) ,
822824 default_lxd_provider ( "torrust-profile-dev" ) ,
823- TrackerConfig :: default ( ) ,
825+ TrackerSection :: default ( ) ,
824826 ) ;
825827
826828 let result = config. to_environment_params ( ) ;
@@ -851,7 +853,7 @@ mod tests {
851853 22 ,
852854 ) ,
853855 default_lxd_provider ( "torrust-profile-test-env" ) ,
854- TrackerConfig :: default ( ) ,
856+ TrackerSection :: default ( ) ,
855857 ) ;
856858
857859 let ( name, _instance_name, provider_config, credentials, port, _tracker) =
@@ -879,7 +881,7 @@ mod tests {
879881 22 ,
880882 ) ,
881883 default_lxd_provider ( "torrust-profile-dev" ) ,
882- TrackerConfig :: default ( ) ,
884+ TrackerSection :: default ( ) ,
883885 ) ;
884886
885887 let json = serde_json:: to_string_pretty ( & original) . unwrap ( ) ;
@@ -967,7 +969,7 @@ mod tests {
967969 22 ,
968970 ) ,
969971 default_lxd_provider ( "test-profile" ) ,
970- TrackerConfig :: default ( ) ,
972+ TrackerSection :: default ( ) ,
971973 ) ;
972974
973975 // Both should serialize to same structure (different values)
0 commit comments