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
+3 -15
View File
@@ -11,7 +11,6 @@ use futures::StreamExt;
use futures::future::join_all;
use minijinja::context;
use thiserror::Error;
use tokio::process::Command;
use crate::cli::{Cli, Commands, GlobalOpts};
@@ -21,16 +20,6 @@ enum Error {
NoClustersFound,
}
async fn run_command(mut command: Command) {
let output = command.output().await.unwrap();
if !output.stdout.is_empty() {
println!("{}", String::from_utf8_lossy(&output.stdout).trim_end());
}
if !output.stderr.is_empty() {
println!("{}", String::from_utf8_lossy(&output.stderr).trim_end());
}
}
async fn generate(opts: &GlobalOpts) -> Result<(), Error> {
set_repo_path(&opts.repo);
@@ -74,22 +63,21 @@ async fn generate(opts: &GlobalOpts) -> Result<(), Error> {
join_all(cluster.nodes().iter().map(|node| {
let cluster = cluster.clone();
async move {
run_command(node.talosctl_gen_config_command(&cluster)).await;
node.config_write(&cluster).await;
}
}))
.await;
// Run these commands in parallel with the the node commands
// NOTE: These do need to happen in the correct order
run_command(cluster.talosctl_gen_config_command()).await;
run_command(cluster.talosctl_add_endpoint_command()).await;
cluster.talosconfig_write().await;
}))
.await;
// Merge all the cluster talosconfig files into a single file
// Since this all modifies the same output file this has to happen sequentially
for cluster in clusters {
run_command(cluster.talosctl_merge_command()).await;
cluster.talosconfig_merge().await;
}
Ok(())