diff --git a/src/main.rs b/src/main.rs index b74f1ad..addc9a9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -39,11 +39,11 @@ fn output_rendered_configs(rendered_config: RenderedConfig, outdir: &str, dbg: L .append(true) .open(&merged_config_path) .expect("unable to open"); - for rendered_template in rendered_config.configs { - let template_path = out_path.join(rendered_template.0 + ".tera"); + for config in rendered_config.configs { + let template_path = out_path.join(config.name + ".tera"); verb!(dbg, " | {}", &template_path.display()); - write(&template_path, &rendered_template.1).ok(); - all_file.write_all(&rendered_template.1.as_bytes()).ok(); + write(&template_path, &config.data).ok(); + all_file.write_all(&config.data.as_bytes()).ok(); } let spec: String = yaml_serde::to_string(&rendered_config.spec).unwrap(); diff --git a/src/tmpls.rs b/src/tmpls.rs index 74e4492..2f8362a 100644 --- a/src/tmpls.rs +++ b/src/tmpls.rs @@ -12,10 +12,15 @@ struct TemplateConfig { pub struct RenderedConfig { pub hostname: String, - pub configs: Vec<(String, String)>, + pub configs: Vec, pub spec: Value, } +pub struct Configuration { + pub name: String, + pub data: String, +} + pub fn process_templates( spec: &Specification, dbg: LogLevel, @@ -89,7 +94,10 @@ pub fn process_templates( eprintln!("[tera] {}", chain); }) .unwrap_or_default(); - configs.push((String::from(&template_name), rendered)); + configs.push(Configuration { + name: String::from(&template_name), + data: rendered, + }); } Ok(RenderedConfig {