Overview
Implement core configuration infrastructure in the domain layer with pure configuration value objects, business validation rules, and explicit error handling.
Parent EPIC: #34 - Implement Create Environment Command
Related: Full Specification | Roadmap Task 1.5
Key Architecture Points
- Configuration uses
SshCredentialsConfig (distinct from adapters::ssh::SshCredentials)
- Converts config strings to domain types (
Username, PathBuf)
- JSON Schema validation is optional - can defer to focus on domain validation first
- All errors implement
.help() methods (tiered help system pattern)
Goals
Module Structure
src/domain/config/
├── mod.rs # Module exports
├── environment_config.rs # EnvironmentCreationConfig value object
├── ssh_credentials_config.rs # SshCredentialsConfig value object
├── errors.rs # ConfigValidationError enum with .help()
├── schema.rs # Optional: JSON Schema validation
└── validation.rs # Optional: Domain validation helpers
Key Types
EnvironmentCreationConfig
pub struct EnvironmentCreationConfig {
pub environment: EnvironmentSection,
pub ssh_credentials: SshCredentialsConfig,
}
impl EnvironmentCreationConfig {
pub fn to_environment_params(self)
-> Result<(EnvironmentName, SshCredentials, u16), CreateConfigError> {
// Convert to existing domain types
}
}
SshCredentialsConfig
pub struct SshCredentialsConfig {
pub private_key_path: String,
pub public_key_path: String,
#[serde(default = "default_ssh_username")]
pub username: String,
#[serde(default = "default_ssh_port")]
pub port: u16,
}
Error Types with .help()
#[derive(Debug, Error)]
pub enum CreateConfigError {
#[error("Invalid environment name")]
InvalidEnvironmentName(#[source] EnvironmentNameError),
#[error("Invalid SSH username")]
InvalidUsername(#[source] UsernameError),
// ... other variants
}
impl CreateConfigError {
pub fn help(&self) -> &'static str {
// Detailed troubleshooting guidance
}
}
Acceptance Criteria
Dependencies
[dependencies]
serde = { version = "1.0", features = ["derive"] }
thiserror = "1.0"
# Optional (can defer):
jsonschema = "0.21" # JSON Schema validation
serde_json = "1.0" # JSON Schema handling
Estimated Time
2-3 hours
Notes
- JSON Schema validation is optional enhancement - domain validation is primary
- Focus on type-safe conversion from config strings to domain types
- Maintain clean separation: config layer vs domain/adapters layer
- All error messages must be actionable with
.help() methods
Overview
Implement core configuration infrastructure in the domain layer with pure configuration value objects, business validation rules, and explicit error handling.
Parent EPIC: #34 - Implement Create Environment Command
Related: Full Specification | Roadmap Task 1.5
Key Architecture Points
SshCredentialsConfig(distinct fromadapters::ssh::SshCredentials)Username,PathBuf).help()methods (tiered help system pattern)Goals
Create configuration value objects that convert to existing domain types
EnvironmentCreationConfigwithto_environment_params()methodSshCredentialsConfig(config layer) distinct fromadapters::ssh::SshCredentialsshared::UsernametypePathBufEnvironmentName::new()validationConfiguration validation
.help()methodsAdd comprehensive unit tests
Environment::new()parametersUsernametype conversion from stringrepository.save(&environment.into_any())Module Structure
Key Types
EnvironmentCreationConfig
SshCredentialsConfig
Error Types with .help()
Acceptance Criteria
EnvironmentCreationConfigdeserializes from JSONto_environment_params()converts to domain types successfully.help()with detailed guidanceEnvironment::new()verifiedDependencies
Estimated Time
2-3 hours
Notes
.help()methods