Skip to content

Commit 34c0f17

Browse files
committed
refactor: complete Phase 2c variables template integration
- Add VariablesTemplate rendering to TofuTemplateRenderer workflow - Integrate dynamic variables.tfvars generation with instance_name parameter - Add hardcoded 'torrust-vm' instance names to provision and container modules - Update project documentation to mark Phase 2c as completed - All validation passed: linters, unit tests, and e2e deployment workflow
1 parent 52aab05 commit 34c0f17

File tree

5 files changed

+194
-30
lines changed

5 files changed

+194
-30
lines changed

docs/refactors/instance-name-parameterization.md

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,14 @@ This refactor aims to eliminate hardcoded "torrust-vm" instance names throughout
1616
- **Phase 2**: Template Parameterization
1717
- ✅ Step 2a: Converted variables.tfvars to Tera template with `{{instance_name}}` placeholder
1818
- ✅ Step 2b: Created template wrapper infrastructure (`VariablesTemplate`, `VariablesContext`)
19+
- ✅ Step 2c: Integrated Variables Template Rendering into workflow
1920

2021
### 🔄 Current Phase
2122

22-
- **Phase 2c**: Integrate Variables Template Rendering (In Progress)
23-
- 🔄 Add `VariablesTemplate` rendering to `RenderOpenTofuTemplatesStep`
23+
- **Phase 3**: Context Integration - Add instance_name to workflow context (Next Priority)
24+
- 🔄 Add `instance_name` field to `TofuContext` struct
2425
- 🔄 Pass `instance_name` context from provision workflow
25-
- 🔄 Replace static `variables.tfvars` with dynamic rendering
26+
- 🔄 Replace hardcoded "torrust-vm" values with dynamic context
2627

2728
### 📋 Remaining Phases
2829

@@ -82,13 +83,18 @@ This refactor aims to eliminate hardcoded "torrust-vm" instance names throughout
8283

8384
**Goal**: Add variables template rendering to infrastructure workflow
8485

85-
#### Step 2c: Add variables rendering to workflow
86-
87-
- 🔄 Add `VariablesTemplate` rendering to `RenderOpenTofuTemplatesStep`
88-
- 🔄 Pass `instance_name` context from provision workflow
89-
- 🔄 Replace static `variables.tfvars` with dynamic rendering
90-
- **Status**: Template wrapper ready, needs integration into workflow
91-
- **Validation**: E2E tests should show dynamic instance naming
86+
#### Step 2c: Integrate Variables Template Rendering into workflow ✅
87+
88+
- ✅ Added `VariablesTemplate` imports to `TofuTemplateRenderer`
89+
- ✅ Added `instance_name` field to `TofuTemplateRenderer` struct
90+
- ✅ Updated `TofuTemplateRenderer::new()` to accept `instance_name` parameter
91+
- ✅ Created `render_variables_template()` method for dynamic rendering
92+
- ✅ Updated `render_tera_templates()` to call variables template rendering
93+
- ✅ Removed `variables.tfvars` from static template files list
94+
- ✅ Added hardcoded "torrust-vm" values for backward compatibility
95+
- ✅ Updated all test constructors to include `instance_name` parameter
96+
- **Status**: Variables template now dynamically renders with `instance_name = "torrust-vm"`
97+
- **Validation**: ✅ All linters + unit tests + e2e tests passed
9298

9399
### Phase 3: Context Integration
94100

project-words.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,4 @@ usermod
6060
значение
6161
ключ
6262
конфиг
63+
файл

src/commands/provision.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ mod tests {
196196
template_manager.clone(),
197197
temp_dir.path(),
198198
ssh_credentials.clone(),
199+
"torrust-vm".to_string(), // TODO: Make this configurable in Phase 3
199200
));
200201

201202
let ansible_renderer = Arc::new(AnsibleTemplateRenderer::new(

src/container.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ impl Services {
5656
template_manager.clone(),
5757
config.build_dir.clone(),
5858
config.ssh_credentials.clone(),
59+
"torrust-vm".to_string(), // TODO: Make this configurable in Phase 3
5960
);
6061

6162
// Create configuration template renderer

0 commit comments

Comments
 (0)