Skip to content

Commit c507113

Browse files
committed
refactor: remove unnecessary static template wrappers
- Remove template wrapper files for static config files that don't use variables - Keep only inventory.yml.tera wrapper that actually needs variable substitution - Update documentation to reflect the simplified approach - Static files are now copied directly without template processing - Reduce code maintenance burden and improve performance Benefits: - Less code to maintain - Simpler architecture - Faster processing for static files - Easier to add new templates when needed
1 parent 47d92a6 commit c507113

File tree

12 files changed

+12
-573
lines changed

12 files changed

+12
-573
lines changed

src/template/context.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,6 @@
44
55
use serde::Serialize;
66

7-
pub trait TemplateContext {
8-
// Marker trait for template contexts
9-
// No required methods - let Tera handle validation during rendering
10-
}
11-
127
/// Context for static templates (no variables needed)
138
#[derive(Serialize, Clone, Debug)]
149
pub struct StaticContext {

src/template/wrappers/ansible/ansible_cfg.rs

Lines changed: 0 additions & 110 deletions
This file was deleted.

src/template/wrappers/ansible/install_docker.rs

Lines changed: 0 additions & 83 deletions
This file was deleted.

src/template/wrappers/ansible/install_docker_compose.rs

Lines changed: 0 additions & 83 deletions
This file was deleted.

src/template/wrappers/ansible/inventory.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
//!
33
//! This template has mandatory variables that must be provided at construction time.
44
5-
use crate::template::context::TemplateContext;
65
use crate::template::{StaticContext, TemplateRenderer};
76
use anyhow::{Context, Result};
87
use serde::Serialize;
@@ -21,15 +20,11 @@ struct InventoryContext {
2120
ansible_ssh_private_key_file: String,
2221
}
2322

24-
impl TemplateContext for InventoryContext {
25-
// No required methods - Tera handles validation
26-
}
27-
2823
impl InventoryTemplate {
2924
/// Creates a new `InventoryTemplate`, validating the template content and variable substitution
3025
///
3126
/// # Errors
32-
///
27+
///
3328
/// Returns an error if:
3429
/// - Template syntax is invalid
3530
/// - Required variables cannot be substituted
@@ -46,6 +41,7 @@ impl InventoryTemplate {
4641

4742
// Create template engine and validate rendering
4843
let template_name = "inventory.yml";
44+
4945
let engine =
5046
crate::template::TemplateEngine::with_template_content(template_name, template_content)
5147
.with_context(|| "Failed to create template engine with content")?;
Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,8 @@
11
//! Ansible template wrappers
22
//!
3-
//! One module per template file in templates/ansible/
4-
5-
pub mod ansible_cfg;
6-
pub mod install_docker;
7-
pub mod install_docker_compose;
3+
//! Contains wrappers only for template files that actually need variable substitution
4+
//! and have the `.tera` extension. Static playbooks and config files are copied directly.
85
pub mod inventory;
9-
pub mod wait_cloud_init;
106

117
// Re-export the main template structs for easier access
12-
pub use ansible_cfg::AnsibleCfgTemplate;
13-
pub use install_docker::InstallDockerTemplate;
14-
pub use install_docker_compose::InstallDockerComposeTemplate;
158
pub use inventory::InventoryTemplate;
16-
pub use wait_cloud_init::WaitCloudInitTemplate;

0 commit comments

Comments
 (0)