diff --git a/src/domain/config/environment_config.rs b/src/application/command_handlers/create/config/environment_config.rs similarity index 97% rename from src/domain/config/environment_config.rs rename to src/application/command_handlers/create/config/environment_config.rs index aea4304f..571a0941 100644 --- a/src/domain/config/environment_config.rs +++ b/src/application/command_handlers/create/config/environment_config.rs @@ -21,7 +21,7 @@ use super::ssh_credentials_config::SshCredentialsConfig; /// # Examples /// /// ```rust -/// use torrust_tracker_deployer_lib::domain::config::{EnvironmentCreationConfig, EnvironmentSection}; +/// use torrust_tracker_deployer_lib::application::command_handlers::create::config::{EnvironmentCreationConfig, EnvironmentSection}; /// /// let json = r#"{ /// "environment": { @@ -66,7 +66,7 @@ impl EnvironmentCreationConfig { /// # Examples /// /// ```rust - /// use torrust_tracker_deployer_lib::domain::config::{ + /// use torrust_tracker_deployer_lib::application::command_handlers::create::config::{ /// EnvironmentCreationConfig, EnvironmentSection, SshCredentialsConfig /// }; /// @@ -117,7 +117,7 @@ impl EnvironmentCreationConfig { /// # Examples /// /// ```rust - /// use torrust_tracker_deployer_lib::domain::config::{ + /// use torrust_tracker_deployer_lib::application::command_handlers::create::config::{ /// EnvironmentCreationConfig, EnvironmentSection, SshCredentialsConfig /// }; /// use torrust_tracker_deployer_lib::domain::Environment; @@ -163,7 +163,7 @@ impl EnvironmentCreationConfig { /// # Examples /// /// ```rust - /// use torrust_tracker_deployer_lib::domain::config::EnvironmentCreationConfig; + /// use torrust_tracker_deployer_lib::application::command_handlers::create::config::EnvironmentCreationConfig; /// /// let template = EnvironmentCreationConfig::template(); /// assert_eq!(template.environment.name, "REPLACE_WITH_ENVIRONMENT_NAME"); @@ -208,7 +208,7 @@ impl EnvironmentCreationConfig { /// # Examples /// /// ```rust,no_run - /// use torrust_tracker_deployer_lib::domain::config::EnvironmentCreationConfig; + /// use torrust_tracker_deployer_lib::application::command_handlers::create::config::EnvironmentCreationConfig; /// use std::path::Path; /// /// # async fn example() -> Result<(), Box> { diff --git a/src/domain/config/errors.rs b/src/application/command_handlers/create/config/errors.rs similarity index 99% rename from src/domain/config/errors.rs rename to src/application/command_handlers/create/config/errors.rs index 759a5cfc..6063951c 100644 --- a/src/domain/config/errors.rs +++ b/src/application/command_handlers/create/config/errors.rs @@ -70,7 +70,7 @@ impl CreateConfigError { /// # Examples /// /// ```rust - /// use torrust_tracker_deployer_lib::domain::config::CreateConfigError; + /// use torrust_tracker_deployer_lib::application::command_handlers::create::config::CreateConfigError; /// use std::path::PathBuf; /// /// let error = CreateConfigError::PrivateKeyNotFound { diff --git a/src/domain/config/mod.rs b/src/application/command_handlers/create/config/mod.rs similarity index 84% rename from src/domain/config/mod.rs rename to src/application/command_handlers/create/config/mod.rs index 0ea1ff99..a4882854 100644 --- a/src/domain/config/mod.rs +++ b/src/application/command_handlers/create/config/mod.rs @@ -1,15 +1,16 @@ -//! Configuration Domain Module +//! Configuration Module for Create Command //! -//! This module provides configuration value objects and validation for creating -//! deployment environments. It sits at the boundary between external configuration +//! This module provides configuration Data Transfer Objects (DTOs) and validation for +//! creating deployment environments. It sits at the boundary between external configuration //! sources (JSON files, CLI arguments, etc.) and the internal domain model. //! //! ## Architecture //! -//! The configuration layer is distinct from both the adapters and domain layers: +//! The configuration DTOs in this module are specific to the create command and are distinct +//! from both the domain and adapter layers: //! -//! - **Configuration Layer** (`domain::config`): String-based configuration objects -//! that deserialize from external sources (JSON, TOML, CLI) +//! - **Configuration DTOs** (`application::command_handlers::create::config`): String-based +//! configuration objects that deserialize from external sources (JSON, TOML, CLI) //! - **Domain Layer** (`domain::environment`): Strongly-typed domain entities //! with business validation //! - **Adapter Layer** (`adapters::ssh`): Infrastructure-specific implementations @@ -43,7 +44,7 @@ //! ## Usage Example //! //! ```rust -//! use torrust_tracker_deployer_lib::domain::config::{ +//! use torrust_tracker_deployer_lib::application::command_handlers::create::config::{ //! EnvironmentCreationConfig, EnvironmentSection, SshCredentialsConfig //! }; //! use torrust_tracker_deployer_lib::domain::Environment; diff --git a/src/domain/config/ssh_credentials_config.rs b/src/application/command_handlers/create/config/ssh_credentials_config.rs similarity index 96% rename from src/domain/config/ssh_credentials_config.rs rename to src/application/command_handlers/create/config/ssh_credentials_config.rs index a6b59dd0..4321b7ec 100644 --- a/src/domain/config/ssh_credentials_config.rs +++ b/src/application/command_handlers/create/config/ssh_credentials_config.rs @@ -27,7 +27,7 @@ const DEFAULT_SSH_PORT: u16 = 22; /// # Examples /// /// ```rust -/// use torrust_tracker_deployer_lib::domain::config::SshCredentialsConfig; +/// use torrust_tracker_deployer_lib::application::command_handlers::create::config::SshCredentialsConfig; /// /// let config = SshCredentialsConfig { /// private_key_path: "fixtures/testing_rsa".to_string(), @@ -63,7 +63,7 @@ impl SshCredentialsConfig { /// # Examples /// /// ```rust - /// use torrust_tracker_deployer_lib::domain::config::SshCredentialsConfig; + /// use torrust_tracker_deployer_lib::application::command_handlers::create::config::SshCredentialsConfig; /// /// let config = SshCredentialsConfig::new( /// "fixtures/testing_rsa".to_string(), @@ -109,7 +109,7 @@ impl SshCredentialsConfig { /// # Examples /// /// ```rust - /// use torrust_tracker_deployer_lib::domain::config::SshCredentialsConfig; + /// use torrust_tracker_deployer_lib::application::command_handlers::create::config::SshCredentialsConfig; /// /// let config = SshCredentialsConfig::new( /// "fixtures/testing_rsa".to_string(), diff --git a/src/application/command_handlers/create/errors.rs b/src/application/command_handlers/create/errors.rs index d5d28e9b..84aedb05 100644 --- a/src/application/command_handlers/create/errors.rs +++ b/src/application/command_handlers/create/errors.rs @@ -6,7 +6,7 @@ use thiserror::Error; -use crate::domain::config::CreateConfigError; +use crate::application::command_handlers::create::config::CreateConfigError; use crate::domain::environment::repository::RepositoryError; /// Errors that can occur during environment creation command execution diff --git a/src/application/command_handlers/create/handler.rs b/src/application/command_handlers/create/handler.rs index 2ee00aa6..97eaf434 100644 --- a/src/application/command_handlers/create/handler.rs +++ b/src/application/command_handlers/create/handler.rs @@ -7,7 +7,7 @@ use std::sync::Arc; use tracing::{info, instrument}; -use crate::domain::config::EnvironmentCreationConfig; +use crate::application::command_handlers::create::config::EnvironmentCreationConfig; use crate::domain::environment::repository::EnvironmentRepository; use crate::domain::environment::{Created, Environment}; use crate::shared::Clock; @@ -42,7 +42,7 @@ use super::errors::CreateCommandHandlerError; /// ```rust,no_run /// use std::sync::Arc; /// use torrust_tracker_deployer_lib::application::command_handlers::create::CreateCommandHandler; -/// use torrust_tracker_deployer_lib::domain::config::{ +/// use torrust_tracker_deployer_lib::application::command_handlers::create::config::{ /// EnvironmentCreationConfig, EnvironmentSection, SshCredentialsConfig /// }; /// use torrust_tracker_deployer_lib::infrastructure::persistence::repository_factory::RepositoryFactory; @@ -153,7 +153,7 @@ impl CreateCommandHandler { /// /// ```rust,no_run /// use torrust_tracker_deployer_lib::application::command_handlers::create::CreateCommandHandler; - /// use torrust_tracker_deployer_lib::domain::config::{ + /// use torrust_tracker_deployer_lib::application::command_handlers::create::config::{ /// EnvironmentCreationConfig, EnvironmentSection, SshCredentialsConfig /// }; /// diff --git a/src/application/command_handlers/create/mod.rs b/src/application/command_handlers/create/mod.rs index 918b0233..301f244a 100644 --- a/src/application/command_handlers/create/mod.rs +++ b/src/application/command_handlers/create/mod.rs @@ -25,7 +25,7 @@ //! ```rust,no_run //! use std::sync::Arc; //! use torrust_tracker_deployer_lib::application::command_handlers::create::CreateCommandHandler; -//! use torrust_tracker_deployer_lib::domain::config::{ +//! use torrust_tracker_deployer_lib::application::command_handlers::create::config::{ //! EnvironmentCreationConfig, EnvironmentSection, SshCredentialsConfig //! }; //! use torrust_tracker_deployer_lib::infrastructure::persistence::repository_factory::RepositoryFactory; @@ -64,6 +64,7 @@ //! } //! ``` +pub mod config; pub mod errors; pub mod handler; diff --git a/src/application/command_handlers/create/tests/builders.rs b/src/application/command_handlers/create/tests/builders.rs index 3a39b9ed..6168ed0e 100644 --- a/src/application/command_handlers/create/tests/builders.rs +++ b/src/application/command_handlers/create/tests/builders.rs @@ -9,8 +9,10 @@ use std::sync::Arc; use chrono::{DateTime, Utc}; use tempfile::TempDir; +use crate::application::command_handlers::create::config::{ + EnvironmentCreationConfig, EnvironmentSection, SshCredentialsConfig, +}; use crate::application::command_handlers::create::CreateCommandHandler; -use crate::domain::config::{EnvironmentCreationConfig, EnvironmentSection, SshCredentialsConfig}; use crate::domain::environment::{Environment, EnvironmentName}; use crate::infrastructure::persistence::repository_factory::RepositoryFactory; use crate::shared::Clock; diff --git a/src/application/command_handlers/create/tests/integration.rs b/src/application/command_handlers/create/tests/integration.rs index 0d060709..59ff9ad5 100644 --- a/src/application/command_handlers/create/tests/integration.rs +++ b/src/application/command_handlers/create/tests/integration.rs @@ -110,7 +110,7 @@ fn it_should_persist_environment_state_to_repository() { #[test] fn it_should_fail_with_invalid_environment_name() { - use crate::domain::config::{ + use crate::application::command_handlers::create::config::{ EnvironmentCreationConfig, EnvironmentSection, SshCredentialsConfig, }; use std::fs; @@ -154,7 +154,7 @@ fn it_should_fail_with_invalid_environment_name() { #[test] fn it_should_fail_when_ssh_private_key_not_found() { - use crate::domain::config::{ + use crate::application::command_handlers::create::config::{ EnvironmentCreationConfig, EnvironmentSection, SshCredentialsConfig, }; diff --git a/src/domain/mod.rs b/src/domain/mod.rs index 8a9235e4..49a9036b 100644 --- a/src/domain/mod.rs +++ b/src/domain/mod.rs @@ -5,7 +5,6 @@ //! //! ## Components //! -//! - `config` - Configuration value objects and validation for environment creation //! - `environment` - Environment module with entity, name validation, and state management //! - `environment::name` - Environment name validation and management //! - `environment::state` - State marker types and type erasure for environment state machine @@ -13,7 +12,6 @@ //! - `profile_name` - LXD profile name validation and management //! - `template` - Core template domain models and business logic -pub mod config; pub mod environment; pub mod instance_name; pub mod profile_name; diff --git a/src/presentation/commands/create/config_loader.rs b/src/presentation/commands/create/config_loader.rs index 4e8cf57d..cd8965fa 100644 --- a/src/presentation/commands/create/config_loader.rs +++ b/src/presentation/commands/create/config_loader.rs @@ -11,7 +11,7 @@ use figment::{ Figment, }; -use crate::domain::config::EnvironmentCreationConfig; +use crate::application::command_handlers::create::config::EnvironmentCreationConfig; use super::errors::{ConfigFormat, CreateSubcommandError}; diff --git a/src/presentation/commands/create/errors.rs b/src/presentation/commands/create/errors.rs index b2636e95..76d6318d 100644 --- a/src/presentation/commands/create/errors.rs +++ b/src/presentation/commands/create/errors.rs @@ -55,7 +55,7 @@ pub enum CreateSubcommandError { ConfigValidationFailed( /// Underlying validation error from domain layer #[source] - crate::domain::config::CreateConfigError, + crate::application::command_handlers::create::config::CreateConfigError, ), /// Command execution failed @@ -71,7 +71,7 @@ pub enum CreateSubcommandError { TemplateGenerationFailed( /// Underlying template generation error from domain layer #[source] - crate::domain::config::CreateConfigError, + crate::application::command_handlers::create::config::CreateConfigError, ), } @@ -216,7 +216,7 @@ mod tests { #[test] fn it_should_have_help_for_all_error_variants() { - use crate::domain::config::CreateConfigError; + use crate::application::command_handlers::create::config::CreateConfigError; use crate::domain::EnvironmentNameError; let errors: Vec = vec![ diff --git a/src/presentation/commands/create/subcommands/environment.rs b/src/presentation/commands/create/subcommands/environment.rs index 346c69ee..84affa35 100644 --- a/src/presentation/commands/create/subcommands/environment.rs +++ b/src/presentation/commands/create/subcommands/environment.rs @@ -7,8 +7,8 @@ use std::path::Path; use std::sync::Arc; use std::time::Duration; +use crate::application::command_handlers::create::config::EnvironmentCreationConfig; use crate::application::command_handlers::create::CreateCommandHandler; -use crate::domain::config::EnvironmentCreationConfig; use crate::infrastructure::persistence::repository_factory::RepositoryFactory; use crate::presentation::user_output::{UserOutput, VerbosityLevel}; use crate::shared::{Clock, SystemClock}; diff --git a/src/presentation/commands/create/subcommands/template.rs b/src/presentation/commands/create/subcommands/template.rs index e61c2b2c..be28f14f 100644 --- a/src/presentation/commands/create/subcommands/template.rs +++ b/src/presentation/commands/create/subcommands/template.rs @@ -5,7 +5,7 @@ use std::path::Path; -use crate::domain::config::EnvironmentCreationConfig; +use crate::application::command_handlers::create::config::EnvironmentCreationConfig; use crate::presentation::user_output::{UserOutput, VerbosityLevel}; use super::super::errors::CreateSubcommandError; diff --git a/src/testing/e2e/tasks/run_create_command.rs b/src/testing/e2e/tasks/run_create_command.rs index 7a547aba..b355544c 100644 --- a/src/testing/e2e/tasks/run_create_command.rs +++ b/src/testing/e2e/tasks/run_create_command.rs @@ -21,10 +21,12 @@ use std::sync::Arc; use thiserror::Error; use tracing::info; +use crate::application::command_handlers::create::config::{ + EnvironmentCreationConfig, EnvironmentSection, SshCredentialsConfig, +}; use crate::application::command_handlers::create::{ CreateCommandHandler, CreateCommandHandlerError, }; -use crate::domain::config::{EnvironmentCreationConfig, EnvironmentSection, SshCredentialsConfig}; use crate::domain::environment::Created; use crate::domain::Environment; use crate::infrastructure::persistence::repository_factory::RepositoryFactory;