diff --git a/Cargo.lock b/Cargo.lock index 85dcb58..4412a04 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -17,6 +17,17 @@ version = "0.2.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" +[[package]] +name = "annotate-snippets" +version = "0.12.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2a5b0a5ab8561c603f16c3b78c24a386b1f70e7fc1b1b1e8c15738828e4a176" +dependencies = [ + "anstyle", + "memchr", + "unicode-width", +] + [[package]] name = "anstream" version = "1.0.0" @@ -76,6 +87,12 @@ dependencies = [ "rustversion", ] +[[package]] +name = "arraydeque" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d902e3d592a523def97af8f317b08ce16b7ab854c1985a0c671e6f15cebc236" + [[package]] name = "async-channel" version = "2.5.0" @@ -480,6 +497,7 @@ dependencies = [ "schemars", "semver", "serde", + "serde-saphyr", "serde_json", "serde_yaml", "socket-pktinfo", @@ -655,6 +673,15 @@ dependencies = [ "simdutf8", ] +[[package]] +name = "encoding_rs_io" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fba3fe847045ecff794b9c138293a80db914678c453ad63fbf0c6a9eb6e00b22" +dependencies = [ + "encoding_rs", +] + [[package]] name = "equivalent" version = "1.0.2" @@ -1805,6 +1832,16 @@ dependencies = [ "zlib-rs", ] +[[package]] +name = "granit-parser" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da55feca5d1625466bae068f9fd4b87892caeae70c3fe671ddb0f50d41aebf37" +dependencies = [ + "arraydeque", + "smallvec", +] + [[package]] name = "h2" version = "0.4.20" @@ -2432,12 +2469,27 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "205c45083b6725eb4671392c7c399510ad1498dd0275f1a2e68a70a34ebdf1b1" +[[package]] +name = "nohash-hasher" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bf50223579dc7cdcfb3bfcacf7069ff68243f8c363f62ffa99cf000a6b9c451" + [[package]] name = "nonempty" version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9737e026353e5cd0736f98eddae28665118eb6f6600902a7f50db585621fecb6" +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + [[package]] name = "num_enum" version = "0.7.6" @@ -3095,6 +3147,23 @@ dependencies = [ "serde_derive", ] +[[package]] +name = "serde-saphyr" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a253edfdea34032da21af84e16fcc94f4c7a6ba237f9f3bc2dbf43cea8535c44" +dependencies = [ + "annotate-snippets", + "base64 0.23.1", + "encoding_rs_io", + "granit-parser", + "nohash-hasher", + "num-traits", + "serde_core", + "smallvec", + "zmij", +] + [[package]] name = "serde_core" version = "1.0.229" @@ -3540,6 +3609,12 @@ dependencies = [ "tinyvec", ] +[[package]] +name = "unicode-width" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4ac048d71ede7ee76d585517add45da530660ef4390e49b098733c6e897f254" + [[package]] name = "unsafe-libyaml" version = "0.2.11" diff --git a/Cargo.toml b/Cargo.toml index 67ee6ad..c307570 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -39,6 +39,7 @@ ipxe = { path = "./ipxe" } axum = { version = "0.8.9", features = ["macros"] } socket2 = "0.6.5" socket-pktinfo = "0.4.1" +serde-saphyr = "2.0.0" [lib] test = false diff --git a/src/cluster.rs b/src/cluster.rs index 7deeae8..8404a6c 100644 --- a/src/cluster.rs +++ b/src/cluster.rs @@ -102,7 +102,7 @@ impl Cluster { path.add_extension("yaml"); let content = tokio::fs::read_to_string(path).await.unwrap(); - let mut cluster: OptionalClusterDeserialize = serde_yaml::from_str(&content).unwrap(); + let mut cluster: OptionalClusterDeserialize = serde_saphyr::from_str(&content).unwrap(); // For some reason apply on the cluster does not properly apply to the default settings... // So we manually apply it here first diff --git a/src/node.rs b/src/node.rs index 14ea4fe..c34265d 100644 --- a/src/node.rs +++ b/src/node.rs @@ -102,7 +102,7 @@ pub struct Node { ntp: String, install: Install, kernel_args: Vec, - patches: Patches, + patches: Patches, sops: Secret, } @@ -124,7 +124,7 @@ impl Node { path.add_extension("yaml"); let content = tokio::fs::read_to_string(path).await.unwrap(); - let node: OptionalNodeDeserialize = serde_yaml::from_str(&content).unwrap(); + let node: OptionalNodeDeserialize = serde_saphyr::from_str(&content).unwrap(); // We want all vectors to be empty vectors by default // Sadly we have to this manually diff --git a/src/patch.rs b/src/patch.rs index d6815ed..471c165 100644 --- a/src/patch.rs +++ b/src/patch.rs @@ -21,7 +21,7 @@ async fn render( env: &Environment<'static>, cluster: &Cluster, node: &Node, -) -> Vec { +) -> Vec { let env = env.clone(); let cluster = cluster.clone(); let node = node.clone(); @@ -40,7 +40,7 @@ async fn render( }) .unwrap(); - serde_yaml::from_str(&content).unwrap() + serde_saphyr::from_str(&content).unwrap() }) .collect() }) @@ -64,7 +64,7 @@ impl Patches { env: &Environment<'static>, cluster: &Cluster, node: &Node, - ) -> Patches { + ) -> Patches { Patches { all: render(self.all.clone(), env, cluster, node).await, control_plane: render(self.control_plane.clone(), env, cluster, node).await, diff --git a/src/talosconfig.rs b/src/talosconfig.rs index d59c20f..0d7a1b4 100644 --- a/src/talosconfig.rs +++ b/src/talosconfig.rs @@ -20,7 +20,7 @@ pub async fn get_current_context() -> Option { tokio::fs::read(&TalosConfig::merged_path()) .await .ok() - .and_then(|config| serde_yaml::from_slice(&config).ok()) + .and_then(|config| serde_saphyr::from_slice(&config).ok()) .map(|config: TalosConfig| config.context) }