#![feature(path_absolute_method, never_type)] use std::path::{Path, PathBuf}; use std::sync::OnceLock; use tokio::process::Command; pub mod cluster; pub mod environment; pub mod node; pub mod patch; pub mod schematic; pub mod secret; pub mod talosconfig; pub mod tftp; pub(crate) static REPO_PATH: OnceLock = OnceLock::new(); pub fn set_repo_path(path: impl Into) { REPO_PATH .set(path.into()) .expect("Repo path already initialized"); } pub fn get_repo_path() -> &'static Path { REPO_PATH.get().expect("Repo path not initialized") } pub fn get_talos_path() -> PathBuf { get_repo_path().join("talos") } pub fn get_configs_path() -> PathBuf { get_repo_path().join("configs") } pub async fn run_command(mut command: Command) -> String { let output = command.output().await.unwrap(); if !output.stderr.is_empty() { println!("{}", String::from_utf8_lossy(&output.stderr).trim_end()); } String::from_utf8_lossy(&output.stdout) .trim_end() .to_owned() }