Skip to content

Commit

Permalink
chore: Update jsonpath-rust to remove lazy_static and once_cell d…
Browse files Browse the repository at this point in the history
…ependencies, slight performance improvement
  • Loading branch information
bryantbiggs committed Nov 7, 2024
1 parent 179936a commit 42affe1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ async-broadcast = "0.7.0"
async-stream = "0.3.5"
async-trait = "0.1.64"
backoff = "0.4.0"
base64 = "0.22.0"
base64 = "0.22.1"
bytes = "1.1.0"
chrono = { version = "0.4.34", default-features = false }
darling = "0.20.3"
Expand All @@ -49,7 +49,7 @@ futures = { version = "0.3.17", default-features = false }
hashbrown = "0.15.0"
home = "0.5.4"
http = "1.1.0"
http-body = "1.0.0"
http-body = "1.0.1"
http-body-util = "0.1.2"
hyper = "1.2.0"
hyper-util = "0.1.9"
Expand All @@ -59,7 +59,7 @@ hyper-socks2 = { version = "0.9.0", default-features = false }
hyper-timeout = "0.5.1"
json-patch = "3"
jsonptr = "0.6"
jsonpath-rust = "0.5.0"
jsonpath-rust = "0.7.3"
k8s-openapi = { version = "0.23.0", default-features = false }
openssl = "0.10.36"
parking_lot = "0.12.0"
Expand All @@ -68,7 +68,7 @@ pin-project = "1.0.4"
proc-macro2 = "1.0.29"
quote = "1.0.10"
rand = "0.8.3"
rustls = { version = "0.23.0", default-features = false }
rustls = { version = "0.23.16", default-features = false }
rustls-pemfile = "2.0.0"
schemars = "0.8.6"
secrecy = "0.10.2"
Expand Down
2 changes: 1 addition & 1 deletion kube-client/src/api/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ enum Dirtiness {
New,
}

impl<'a, K> OccupiedEntry<'a, K> {
impl<K> OccupiedEntry<'_, K> {
/// Borrow the object
pub fn get(&self) -> &K {
&self.object
Expand Down
11 changes: 5 additions & 6 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::{path::config::JsonPathConfig, JsonPathInst};
use jsonpath_rust::JsonPath;
use secrecy::{ExposeSecret, SecretString};
use serde::{Deserialize, Serialize};
use thiserror::Error;
Expand Down Expand Up @@ -498,31 +498,30 @@ 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>()
.parse::<JsonPath>()
.map_err(|err| {
Error::AuthExec(format!(
"Failed to parse {context:?} as a JsonPath: {path}\n
Error: {err}"
))
})?;

let res = parsed_path.find_slice(json, cfg);
let res = parsed_path.find_slice(json);

let Some(res) = res.into_iter().next() else {
return Err(Error::AuthExec(format!(
"Target {context:?} value {path:?} not found"
)));
};

if let Some(val) = res.as_str() {
if let Some(val) = res.clone().to_path() {
Ok(val.to_owned())
} else {
Err(Error::AuthExec(format!(
"Target {:?} value {:?} is not a string: {:?}",
context, path, *res
context, path, res
)))
}
}
Expand Down

0 comments on commit 42affe1

Please sign in to comment.