From 79a1ec956b357cb70bb9b7f093d8f64698eb000b Mon Sep 17 00:00:00 2001 From: clux Date: Mon, 18 Mar 2024 16:21:22 +0000 Subject: [PATCH] upgrade jsonpath-rust to 0.5.0 manual handling of breaking change Signed-off-by: clux --- examples/Cargo.toml | 2 +- examples/dynamic_jsonpath.rs | 2 +- kube-client/Cargo.toml | 2 +- kube-client/src/client/auth/mod.rs | 5 +++-- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/examples/Cargo.toml b/examples/Cargo.toml index 760003f2a..baf14a47f 100644 --- a/examples/Cargo.toml +++ b/examples/Cargo.toml @@ -30,7 +30,7 @@ assert-json-diff = "2.0.1" garde = { version = "0.18.0", default-features = false, features = ["derive"] } anyhow = "1.0.44" futures = "0.3.17" -jsonpath-rust = "0.4.0" +jsonpath-rust = "0.5.0" kube = { path = "../kube", version = "^0.88.1", default-features = false, features = ["admission"] } kube-derive = { path = "../kube-derive", version = "^0.88.1", default-features = false } # only needed to opt out of schema k8s-openapi = { version = "0.21.0", default-features = false } diff --git a/examples/dynamic_jsonpath.rs b/examples/dynamic_jsonpath.rs index 09994f555..3fb670b84 100644 --- a/examples/dynamic_jsonpath.rs +++ b/examples/dynamic_jsonpath.rs @@ -34,7 +34,7 @@ async fn main() -> anyhow::Result<()> { // Use the given JSONPATH to filter the ObjectList let list_json = serde_json::to_value(&list)?; - for res in jsonpath.find_slice(&list_json) { + for res in jsonpath.find_slice(&list_json, Default::default()) { info!("\t\t {}", *res); } Ok(()) diff --git a/kube-client/Cargo.toml b/kube-client/Cargo.toml index aa757bb6f..f8e474f31 100644 --- a/kube-client/Cargo.toml +++ b/kube-client/Cargo.toml @@ -57,7 +57,7 @@ rustls-pemfile = { version = "1.0.0", optional = true } bytes = { version = "1.1.0", optional = true } tokio = { version = "1.14.0", features = ["time", "signal", "sync"], optional = true } kube-core = { path = "../kube-core", version = "=0.88.1" } -jsonpath-rust = { version = "0.4.0", optional = true } +jsonpath-rust = { version = "0.5.0", optional = true } tokio-util = { version = "0.7.0", optional = true, features = ["io", "codec"] } hyper = { version = "0.14.13", optional = true, features = ["client", "http1", "stream", "tcp"] } hyper-rustls = { version = "0.24.0", optional = true } diff --git a/kube-client/src/client/auth/mod.rs b/kube-client/src/client/auth/mod.rs index eaca2d8ea..073b5825d 100644 --- a/kube-client/src/client/auth/mod.rs +++ b/kube-client/src/client/auth/mod.rs @@ -10,7 +10,7 @@ use http::{ header::{InvalidHeaderValue, AUTHORIZATION}, HeaderValue, Request, }; -use jsonpath_rust::JsonPathInst; +use jsonpath_rust::{path::config::JsonPathConfig, JsonPathInst}; use secrecy::{ExposeSecret, SecretString}; use serde::{Deserialize, Serialize}; use thiserror::Error; @@ -479,6 +479,7 @@ fn token_from_gcp_provider(provider: &AuthProviderConfig) -> Result Result { + let cfg = JsonPathConfig::default(); // no need for regex caching here let parsed_path = path .trim_matches(|c| c == '"' || c == '{' || c == '}') .parse::() @@ -489,7 +490,7 @@ fn extract_value(json: &serde_json::Value, context: &str, path: &str) -> Result< )) })?; - let res = parsed_path.find_slice(json); + let res = parsed_path.find_slice(json, cfg); let Some(res) = res.into_iter().next() else { return Err(Error::AuthExec(format!(