Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down Expand Up @@ -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
/// };
///
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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<dyn std::error::Error>> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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(),
Expand Down
2 changes: 1 addition & 1 deletion src/application/command_handlers/create/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/application/command_handlers/create/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
/// };
///
Expand Down
3 changes: 2 additions & 1 deletion src/application/command_handlers/create/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -64,6 +64,7 @@
//! }
//! ```

pub mod config;
pub mod errors;
pub mod handler;

Expand Down
4 changes: 3 additions & 1 deletion src/application/command_handlers/create/tests/builders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/application/command_handlers/create/tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
};

Expand Down
2 changes: 0 additions & 2 deletions src/domain/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@
//!
//! ## 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
//! - `instance_name` - LXD instance name validation and management
//! - `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;
Expand Down
2 changes: 1 addition & 1 deletion src/presentation/commands/create/config_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down
6 changes: 3 additions & 3 deletions src/presentation/commands/create/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
),
}

Expand Down Expand Up @@ -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<CreateSubcommandError> = vec![
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
2 changes: 1 addition & 1 deletion src/presentation/commands/create/subcommands/template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 3 additions & 1 deletion src/testing/e2e/tasks/run_create_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading