Skip to content

[Subissue 6/7] Template System Integration (Optional) #40

@josecelano

Description

@josecelano

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 TemplateManager from src/domain/template/embedded.rs for 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 TemplateManagerError for 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 --generate-template functionality 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 TemplateManager infrastructure
  • 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 TemplateManager from src/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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions