feat: Initial rewrite of python render tool

This commit is contained in:
2026-03-16 03:14:33 +01:00
commit e4d39de2f0
24 changed files with 4453 additions and 0 deletions
+33
View File
@@ -0,0 +1,33 @@
use schemars::JsonSchema;
use serde::{Deserialize, Deserializer, Serialize};
use crate::get_talos_config_path;
fn deserialize_schematic<'de, D>(deserializer: D) -> Result<String, D::Error>
where
D: Deserializer<'de>,
{
let name: String = Deserialize::deserialize(deserializer)?;
let path = get_talos_config_path().join("schematics").join(name);
let content = std::fs::read_to_string(path).unwrap().trim().to_owned();
let client = reqwest::blocking::Client::new();
let res = client
.post("https://factory.talos.dev/schematics")
.body(content)
.send()
.map_err(serde::de::Error::custom)?;
#[derive(Debug, Deserialize)]
struct Response {
id: String,
}
let response: Response = serde_json::from_str(&res.text().map_err(serde::de::Error::custom)?)
.map_err(serde::de::Error::custom)?;
Ok(response.id)
}
#[derive(Debug, Serialize, Deserialize, JsonSchema, Clone, PartialEq, Eq)]
pub(crate) struct Schematic(#[serde(deserialize_with = "deserialize_schematic")] String);