Repository navigation
Description
Parent Epic: #34 - Implement Create Environment Command
Status: OPTIONAL ENHANCEMENT
Estimated Time: 2-3 hours
⚠️ Note: This is an optional enhancement that can be deferred. It is not required for the MVP functionality of the create command.
Overview
Implement the template system for configuration file generation in the infrastructure layer. This system provides embedded JSON configuration templates that can be generated on-demand, supporting the --generate-template functionality with proper error handling and validation.
Goals
- Extend existing
TemplateManagerfromsrc/domain/template/embedded.rsfor configuration templates- Use existing template infrastructure - no duplication needed
- Add configuration template types to existing embedded template system
- Leverage existing rust-embed pattern in
templates/directory structure - Use existing
TemplateManagerErrorfor error handling
- Add configuration templates to existing template structure
- Add to existing
templates/directory following existing patterns - Use existing Tera variable syntax:
{{ variable_name }}(not{ { variable_name } }) - Follow existing template embedding and extraction patterns
- Add to existing
- Add
--generate-templatefunctionality using existing template infrastructure - Add unit tests that integrate with existing template system
Architecture Requirements
DDD Layer: Infrastructure Layer (src/infrastructure/templates/)
Pattern: Template Provider + Embedded Resources + File Operations
Dependencies: None (infrastructure concern)
Template Example
{
"environment": {
"name": "{{ environment_name }}"
},
"ssh_credentials": {
"private_key_path": "{{ ssh_private_key_path }}",
"public_key_path": "{{ ssh_public_key_path }}",
"username": "{{ ssh_username }}",
"port": {{ ssh_port }}
}
}Acceptance Criteria
- Template provider extends existing
TemplateManagerinfrastructure - Templates use correct Tera variable syntax:
{{ variable }} - Templates generate valid JSON files
- Error handling follows tiered help system pattern
- Unit tests verify template generation works correctly
- Integration tests verify file system operations
- Templates are embedded in binary using existing rust-embed pattern
Implementation Notes
- Reuse existing
TemplateManagerfromsrc/domain/template/embedded.rs - Add configuration templates to
templates/directory structure - Use existing error types from template system
- Follow patterns established in OpenTofu/Ansible template management
For detailed specification, see: docs/issues/epic-create-environment-command-subissue-6-template-system-integration.md
Activity
docs: [#34] create GitHub issues for Create Environment Command EPIC
feat: [#40] implement infrastructure templates module
fix: [#40] make template validation extensible for future formats
docs: [#40] revise approach to struct-based template generation
josecelano commentedon Oct 27, 2025
Approach Revision: Struct-Based Template Generation
After starting implementation, I've revised the approach for this issue to use struct-based JSON generation instead of embedded templates.
Why the Change?
The original specification suggested using the existing
TemplateManagersystem, but this led to confusion:EnvironmentCreationConfigstructCreating a separate template file would duplicate the struct definition and require manual synchronization.
New Approach
Generate the template directly from the Rust struct:
Benefits:
Updated Documentation
The v2 spec includes:
Impact
src/domain/config/) not infrastructureTemplateManagersystem (they're for different purposes)This change makes the codebase more maintainable and eliminates an entire category of potential sync issues between code and templates.
refactor: [#40] use struct-based template generation instead of hardc…
Merge #48: feat: [#40] Add struct-based template generation for confi…
Merge #49: Add template subcommand for create command
chore: remove closed issue documentation files