Skip to content

Commit

Permalink
upgrade jsonpath-rust to 0.5.0 (#1429)
Browse files Browse the repository at this point in the history
upgrade jsonpath-rust to 0.5.0

manual handling of breaking change

Signed-off-by: clux <[email protected]>
  • Loading branch information
clux authored Mar 19, 2024
1 parent 77852d9 commit 73832c6
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion examples/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
2 changes: 1 addition & 1 deletion examples/dynamic_jsonpath.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
Expand Down
2 changes: 1 addition & 1 deletion kube-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
5 changes: 3 additions & 2 deletions kube-client/src/client/auth/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -479,6 +479,7 @@ fn token_from_gcp_provider(provider: &AuthProviderConfig) -> Result<ProviderToke
}

fn extract_value(json: &serde_json::Value, context: &str, path: &str) -> Result<String, Error> {
let cfg = JsonPathConfig::default(); // no need for regex caching here
let parsed_path = path
.trim_matches(|c| c == '"' || c == '{' || c == '}')
.parse::<JsonPathInst>()
Expand All @@ -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!(
Expand Down

0 comments on commit 73832c6

Please sign in to comment.