refactor: Deduplicate paths
This commit is contained in:
+9
-3
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user