feat: Configs are captured in a string first

This commit is contained in:
2026-10-04 05:53:15 +02:00
parent 1ad7a928ae
commit 35aedf1d5b
4 changed files with 54 additions and 32 deletions
+17 -7
View File
@@ -10,7 +10,7 @@ use crate::cluster::{Base, Cluster};
use crate::patch::{OptionalPatches, OptionalPatchesString, Patches};
use crate::schematic::Schematic;
use crate::secret::Secret;
use crate::{get_configs_path, get_talos_path};
use crate::{get_configs_path, get_talos_path, run_command};
#[derive(Debug, Serialize, Deserialize, JsonSchema, Clone, Copy, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
@@ -177,10 +177,7 @@ impl Node {
Node { patches, ..node }
}
pub fn talosctl_gen_config_command(&self, cluster: &Cluster) -> Command {
let mut path = get_configs_path().join(&cluster.name).join(&self.hostname);
path.add_extension("yaml");
pub async fn config(&self, cluster: &Cluster) -> String {
let mut command = Command::new("talosctl");
command.args([
"gen",
@@ -204,7 +201,7 @@ impl Node {
"--with-docs=false",
"--with-examples=false",
"-o",
path.to_str().expect("Path should be valid utf-8"),
"-",
]);
for patch in &self.patches.all {
@@ -218,7 +215,20 @@ impl Node {
]);
}
command
run_command(command).await
}
pub async fn config_write(&self, cluster: &Cluster) {
let config = self.config(cluster).await;
let mut path = get_configs_path().join(&cluster.name).join(&self.hostname);
path.add_extension("yaml");
tokio::fs::create_dir_all(path.parent().expect("config should have parent"))
.await
.unwrap();
tokio::fs::write(path, config).await.unwrap();
}
}