diff --git a/Cargo.lock b/Cargo.lock index 830abe1..d06d5f1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -287,6 +287,15 @@ version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + [[package]] name = "bumpalo" version = "3.14.0" @@ -381,6 +390,25 @@ version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" +[[package]] +name = "cpufeatures" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" +dependencies = [ + "libc", +] + +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "typenum", +] + [[package]] name = "darling" version = "0.20.9" @@ -431,6 +459,16 @@ version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "56254986775e3233ffa9c4d7d3faaf6d36a2c09d30b20687e9f88bc8bafc16c8" +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer", + "crypto-common", +] + [[package]] name = "dirs" version = "5.0.1" @@ -489,6 +527,15 @@ dependencies = [ "serde", ] +[[package]] +name = "fluent-uri" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17c704e9dbe1ddd863da1e6ff3567795087b1eb201ce80d8fa81162e1516500d" +dependencies = [ + "bitflags 1.3.2", +] + [[package]] name = "fnv" version = "1.0.7" @@ -624,6 +671,16 @@ dependencies = [ "syn", ] +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", +] + [[package]] name = "getrandom" version = "0.2.11" @@ -697,6 +754,30 @@ version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" +[[package]] +name = "headers" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "322106e6bd0cba2d5ead589ddb8150a13d7c4217cf80d7c4f682ca994ccc6aa9" +dependencies = [ + "base64 0.21.5", + "bytes", + "headers-core", + "http 1.1.0", + "httpdate", + "mime", + "sha1", +] + +[[package]] +name = "headers-core" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "54b4a22553d4242c49fddb9ba998a99962b5cc6f22cb5a3482bec22522403ce4" +dependencies = [ + "http 1.1.0", +] + [[package]] name = "heck" version = "0.4.1" @@ -822,6 +903,26 @@ dependencies = [ "want", ] +[[package]] +name = "hyper-http-proxy" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d06dbdfbacf34d996c6fb540a71a684a7aae9056c71951163af8a8a4c07b9a4" +dependencies = [ + "bytes", + "futures-util", + "headers", + "http 1.1.0", + "hyper 1.3.1", + "hyper-rustls", + "hyper-util", + "pin-project-lite", + "rustls-native-certs", + "tokio", + "tokio-rustls 0.26.0", + "tower-service", +] + [[package]] name = "hyper-rustls" version = "0.27.1" @@ -956,14 +1057,25 @@ dependencies = [ [[package]] name = "json-patch" -version = "1.2.0" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55ff1e1486799e3f64129f8ccad108b38290df9cd7015cd31bed17239f0789d6" +checksum = "5b1fb8864823fad91877e6caea0baca82e49e8db50f8e5c9f9a453e27d3330fc" dependencies = [ + "jsonptr", "serde", "serde_json", "thiserror", - "treediff", +] + +[[package]] +name = "jsonptr" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c6e529149475ca0b2820835d3dce8fcc41c6b943ca608d32f35b449255e4627" +dependencies = [ + "fluent-uri", + "serde", + "serde_json", ] [[package]] @@ -982,9 +1094,9 @@ dependencies = [ [[package]] name = "kube" -version = "0.91.0" +version = "0.92.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "264461a7ebf4fb0fcf23e4c7e4f9387c5696ee61d003de207d9b5a895ff37bfa" +checksum = "12dc4487eda98835dcaa7ac92a14165446db29dbd67a743c79fe9f41bf38ee72" dependencies = [ "k8s-openapi", "kube-client", @@ -994,11 +1106,12 @@ dependencies = [ [[package]] name = "kube-client" -version = "0.91.0" +version = "0.92.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47164ad6c47398ee4bdf90509c7b44026229721cb1377eb4623a1ec2a00a85e9" +checksum = "408f35eab36927d3b883e4ad54c3080ea8c49f899ac84a7856e7182e4ee3b392" dependencies = [ "http 1.1.0", + "hyper-http-proxy", "hyper-rustls", "k8s-openapi", "kube-core", @@ -1012,9 +1125,9 @@ dependencies = [ [[package]] name = "kube-core" -version = "0.91.0" +version = "0.92.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2797d3044a238825432129cd9537e12c2a6dacbbb5352381af5ea55e1505ed4f" +checksum = "f776624097c1e09e72eb1e9e0c2bb5d17d97c27a6a87734390a9fba246a8f67f" dependencies = [ "chrono", "form_urlencoded", @@ -1029,9 +1142,9 @@ dependencies = [ [[package]] name = "kube-derive" -version = "0.91.0" +version = "0.92.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcf837edaa0c478f85e9a3cddb17fa80d58a57c1afa722b3a9e55753ea162f41" +checksum = "8ae07adfd7d21b7fa582789206391243f98e155b46c806eb494839569853bcfd" dependencies = [ "darling", "proc-macro2", @@ -1164,6 +1277,7 @@ dependencies = [ "axum-test", "envtestkit", "json-patch", + "jsonptr", "k8s-openapi", "kube", "log", @@ -2027,6 +2141,17 @@ dependencies = [ "serde", ] +[[package]] +name = "sha1" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + [[package]] name = "sharded-slab" version = "0.1.7" @@ -2540,21 +2665,18 @@ dependencies = [ "tracing-serde", ] -[[package]] -name = "treediff" -version = "4.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52984d277bdf2a751072b5df30ec0377febdb02f7696d64c2d7d54630bac4303" -dependencies = [ - "serde_json", -] - [[package]] name = "try-lock" version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" +[[package]] +name = "typenum" +version = "1.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" + [[package]] name = "unicase" version = "2.7.0" diff --git a/Cargo.toml b/Cargo.toml index 21abe1b..b859d94 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,9 +9,9 @@ edition = "2021" anyhow = "1.0.86" axum = { version = "0.7.5", features = ["tracing", "http2", "macros"] } axum-server = { version = "0.6.0", features = ["rustls", "tls-rustls"] } -json-patch = "1.2.0" +json-patch = "2.0.0" k8s-openapi = { version = "0.22.0", default-features = false, features = ["v1_24", "schemars"] } -kube = { version = "0.91.0", features = ["rustls-tls", "admission", "jsonpatch", "derive"], default-features = false } +kube = { version = "0.92.0", features = ["rustls-tls", "admission", "jsonpatch", "derive"], default-features = false } log = { version = "0.4.21", features = ["kv_unstable", "serde", "kv_unstable_serde"] } schemars = { version = "0.8.21", features = ["derive_json_schema"] } serde = { version = "1.0.203", features = ["serde_derive", "derive"] } @@ -25,6 +25,7 @@ opentelemetry-otlp = { version = "0.16.0", features = ["opentelemetry-http"] } opentelemetry-semantic-conventions = "0.15.0" opentelemetry_sdk = { version = "0.23.0", features = ["rt-tokio"] } schematic = "0.16.4" +jsonptr = "0.4.7" [dev-dependencies] axum-test = "15.2.0" diff --git a/flake.lock b/flake.lock index 13ab25c..bcb4b82 100644 --- a/flake.lock +++ b/flake.lock @@ -2,21 +2,16 @@ "nodes": { "crane": { "inputs": { - "flake-compat": "flake-compat", - "flake-utils": [ - "flake-utils" - ], "nixpkgs": [ "nixpkgs" - ], - "rust-overlay": "rust-overlay" + ] }, "locked": { - "lastModified": 1686186025, - "narHash": "sha256-SuQjKsO1G87qM5j8VNtq6kIw4ILYE03Y8yL/FoKwR+4=", + "lastModified": 1717025063, + "narHash": "sha256-dIubLa56W9sNNz0e8jGxrX3CAkPXsq7snuFA/Ie6dn8=", "owner": "ipetkov", "repo": "crane", - "rev": "057d95721ee67d421391dda7031977d247ddec28", + "rev": "480dff0be03dac0e51a8dfc26e882b0d123a450e", "type": "github" }, "original": { @@ -25,32 +20,16 @@ "type": "github" } }, - "flake-compat": { - "flake": false, - "locked": { - "lastModified": 1673956053, - "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", - "owner": "edolstra", - "repo": "flake-compat", - "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", - "type": "github" - }, - "original": { - "owner": "edolstra", - "repo": "flake-compat", - "type": "github" - } - }, "flake-utils": { "inputs": { "systems": "systems" }, "locked": { - "lastModified": 1685518550, - "narHash": "sha256-o2d0KcvaXzTrPRIo0kOLV0/QXHhDQ5DTi+OxcjO8xqY=", + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", "owner": "numtide", "repo": "flake-utils", - "rev": "a1720a10a6cfe8234c0e93907ffe81be440f4cef", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", "type": "github" }, "original": { @@ -61,11 +40,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1686327234, - "narHash": "sha256-wbCiKLU+V3nNnCgtRnw4RvYyL7mZoU4mi3Z6UtyorpU=", + "lastModified": 1717151749, + "narHash": "sha256-cf/DCdZjfKUjb/2xKGFxxEKgJzkIROJj20uaAnY5/EI=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "a175ac6ba894f5775b4fd95eabaa2cfff5b4a419", + "rev": "2dc0bf5786f1fcc0445013249c48f207312b7c8d", "type": "github" }, "original": { @@ -79,35 +58,10 @@ "crane": "crane", "flake-utils": "flake-utils", "nixpkgs": "nixpkgs", - "rust-overlay": "rust-overlay_2" + "rust-overlay": "rust-overlay" } }, "rust-overlay": { - "inputs": { - "flake-utils": [ - "crane", - "flake-utils" - ], - "nixpkgs": [ - "crane", - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1685759304, - "narHash": "sha256-I3YBH6MS3G5kGzNuc1G0f9uYfTcNY9NYoRc3QsykLk4=", - "owner": "oxalica", - "repo": "rust-overlay", - "rev": "c535b4f3327910c96dcf21851bbdd074d0760290", - "type": "github" - }, - "original": { - "owner": "oxalica", - "repo": "rust-overlay", - "type": "github" - } - }, - "rust-overlay_2": { "inputs": { "flake-utils": [ "flake-utils" @@ -117,11 +71,11 @@ ] }, "locked": { - "lastModified": 1686277999, - "narHash": "sha256-Lko8PiXN8ecQSlFsn/7V5fyoUtb1H5zyMpe73hLmSis=", + "lastModified": 1717121863, + "narHash": "sha256-/3sxIe7MZqF/jw1RTQCSmgTjwVod43mmrk84m50MJQ4=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "f46177d472fc5b754fd5ad382ae8a31a10979750", + "rev": "2a7b53172ed08f856b8382d7dcfd36a4e0cbd866", "type": "github" }, "original": { diff --git a/src/mutators.rs b/src/mutators.rs index a3b7a9e..33db7a3 100644 --- a/src/mutators.rs +++ b/src/mutators.rs @@ -1,13 +1,14 @@ use std::collections::BTreeMap; use std::sync::Arc; +use crate::aiven_object::AivenObject; +use crate::settings::AppConfig; use json_patch::PatchOperation; +use jsonptr::Pointer; use serde_json::{json, Value}; +use std::str::FromStr; use tracing::{debug, info, instrument}; -use crate::aiven_object::AivenObject; -use crate::settings::AppConfig; - #[instrument(skip_all)] pub fn add_location( location: String, @@ -106,11 +107,17 @@ pub fn add_project_vpc_id( } fn add_patch(path: String, value: Value) -> PatchOperation { - PatchOperation::Add(json_patch::AddOperation { path, value }) + PatchOperation::Add(json_patch::AddOperation { + path: Pointer::from_str(&path).unwrap(), + value, + }) } fn replace_patch(path: String, value: Value) -> PatchOperation { - PatchOperation::Replace(json_patch::ReplaceOperation { path, value }) + PatchOperation::Replace(json_patch::ReplaceOperation { + path: Pointer::from_str(&path).unwrap(), + value, + }) } #[cfg(test)] @@ -272,15 +279,17 @@ mod tests { .clone() .into_iter() .map(|p| match p { - PatchOperation::Add(add) => { - ("add", add.path, add.value.as_str().unwrap().to_string()) - }, + PatchOperation::Add(add) => ( + "add", + add.path.to_string(), + add.value.as_str().unwrap().to_string(), + ), PatchOperation::Replace(replace) => ( "replace", - replace.path, + replace.path.to_string(), replace.value.as_str().unwrap().to_string(), ), - _ => ("invalid", "invalid".to_string(), String::new()), + _ => panic!(), }) .collect() }