Task: Update UserInputs to use ProviderConfig
Epic: #205 - Add Hetzner Provider Support
Phase: 1 - Make LXD Explicit
Dependencies: #206 (Add Provider enum and ProviderConfig types)
Overview
Refactor the domain UserInputs struct to include provider configuration. This moves profile_name from being a global field to being part of LxdConfig, making provider-specific configuration explicit.
Current State
// src/domain/user_inputs.rs (current)
pub struct UserInputs {
pub instance_name: InstanceName,
pub profile_name: ProfileName, // LXD-specific, but treated as global
// ... other fields
}
Target State
// src/domain/user_inputs.rs (after this task)
use crate::domain::provider::ProviderConfig;
pub struct UserInputs {
pub instance_name: InstanceName, // Kept global - all providers need it
pub provider_config: ProviderConfig, // Provider-specific config
// ... other fields
}
impl UserInputs {
/// Returns the LXD profile name if using LXD provider.
///
/// # Panics
///
/// Panics if not using LXD provider.
pub fn lxd_profile_name(&self) -> &ProfileName {
self.provider_config.as_lxd().profile_name
}
/// Returns the provider type.
pub fn provider(&self) -> Provider {
self.provider_config.provider()
}
}
Implementation Steps
- Add import for
ProviderConfig from crate::domain::provider
- Add
provider_config field to UserInputs
- Remove
profile_name field from UserInputs (it's now in LxdConfig)
- Add accessor methods for provider-specific fields
- Update all usages of
user_inputs.profile_name throughout codebase
Code Changes Required
Files to Modify
src/domain/user_inputs.rs - Main struct changes
- All files that access
user_inputs.profile_name - Update to use accessor
- Tests that construct
UserInputs - Update to include provider_config
Finding Usages
Search for:
user_inputs.profile_name
profile_name: in struct construction
UserInputs { struct literals
DDD Compliance
This change maintains DDD principles:
UserInputs remains in domain layer (semantic meaning: "what the user wants")
ProviderConfig is in domain layer (semantic meaning: "provider-specific validated configuration")
ProviderSection stays in application layer (raw JSON parsing)
- The conversion
ProviderSection → ProviderConfig happens in application layer before constructing UserInputs
Testing Requirements
Unit Tests
Integration Tests
Acceptance Criteria
Notes
Related
Task: Update UserInputs to use ProviderConfig
Epic: #205 - Add Hetzner Provider Support
Phase: 1 - Make LXD Explicit
Dependencies: #206 (Add Provider enum and ProviderConfig types)
Overview
Refactor the domain
UserInputsstruct to include provider configuration. This movesprofile_namefrom being a global field to being part ofLxdConfig, making provider-specific configuration explicit.Current State
Target State
Implementation Steps
ProviderConfigfromcrate::domain::providerprovider_configfield toUserInputsprofile_namefield fromUserInputs(it's now inLxdConfig)user_inputs.profile_namethroughout codebaseCode Changes Required
Files to Modify
src/domain/user_inputs.rs- Main struct changesuser_inputs.profile_name- Update to use accessorUserInputs- Update to includeprovider_configFinding Usages
Search for:
user_inputs.profile_nameprofile_name:in struct constructionUserInputs {struct literalsDDD Compliance
This change maintains DDD principles:
UserInputsremains in domain layer (semantic meaning: "what the user wants")ProviderConfigis in domain layer (semantic meaning: "provider-specific validated configuration")ProviderSectionstays in application layer (raw JSON parsing)ProviderSection → ProviderConfighappens in application layer before constructingUserInputsTesting Requirements
Unit Tests
UserInputsconstruction with LXD provider configUserInputsconstruction with Hetzner provider configlxd_profile_name()accessor returns correct valuelxd_profile_name()panics for non-LXD providerprovider()method returns correct variantIntegration Tests
UserInputsAcceptance Criteria
UserInputshasprovider_config: ProviderConfigfieldprofile_namefield removed fromUserInputs(moved toLxdConfig)instance_nameremains as global field inUserInputsprofile_nameupdatedNotes
user_inputs.profile_nametouser_inputs.lxd_profile_name()is a breaking change for internal codeRelated