refactor: Deduplicate paths

This commit is contained in:
2026-10-04 05:53:18 +02:00
parent 88405a1e63
commit cae78a31a8
3 changed files with 38 additions and 20 deletions
+9 -3
View File
@@ -1,4 +1,5 @@
use std::net::Ipv4Addr;
use std::path::PathBuf;
use minijinja::Environment;
use optional_struct::{Applicable, optional_struct};
@@ -218,12 +219,17 @@ impl Node {
run_command(command).await
}
pub async fn config_write(&self, cluster: &Cluster) {
let config = self.config(cluster).await;
pub fn config_path(&self, cluster: &Cluster) -> PathBuf {
let mut path = get_configs_path().join(&cluster.name).join(&self.hostname);
path.add_extension("yaml");
path
}
pub async fn config_write(&self, cluster: &Cluster) {
let config = self.config(cluster).await;
let path = self.config_path(cluster);
tokio::fs::create_dir_all(path.parent().expect("config should have parent"))
.await
.unwrap();