Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ secrecy = "0.10.2"
serde = "1.0.130"
serde_json = "1.0.68"
serde_yaml = "0.9.19"
serde-saphyr = "0.0.8"
serde-value = "0.7.0"
syn = "2.0.38"
tame-oauth = "0.10.0"
Expand Down
8 changes: 8 additions & 0 deletions deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,11 @@ name = "getrandom"
name = "wasi"
[[bans.skip]]
name = "zerocopy"

# serde-saphyr 0.0.8 pulls in different versions of these three crates
[[bans.skip]]
name = "foldhash"
[[bans.skip]]
name = "hashbrown"
[[bans.skip]]
name = "smallvec"
4 changes: 2 additions & 2 deletions kube-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ http-proxy = ["hyper-util/client-proxy"]
unstable-client = []

# private feature sets; do not use
__non_core = ["tracing", "serde_yaml", "base64"]
__non_core = ["tracing", "serde-saphyr", "base64"]

[package.metadata.docs.rs]
features = ["client", "rustls-tls", "openssl-tls", "ws", "oauth", "oidc", "jsonpatch", "admission", "k8s-openapi/latest", "socks5", "unstable-client", "http-proxy"]
Expand All @@ -47,7 +47,7 @@ base64 = { workspace = true, optional = true }
chrono = { workspace = true, optional = true }
serde = { workspace = true, features = ["derive"] }
serde_json.workspace = true
serde_yaml = { workspace = true, optional = true }
serde-saphyr = { workspace = true, optional = true }
http.workspace = true
http-body = { workspace = true, optional = true }
http-body-util = { workspace = true, optional = true }
Expand Down
2 changes: 1 addition & 1 deletion kube-client/src/client/auth/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,7 @@ mod test {
"#
);

let config: Kubeconfig = serde_yaml::from_str(&test_file).unwrap();
let config: Kubeconfig = serde_saphyr::from_str(&test_file).unwrap();
let auth_info = config.auth_infos[0].auth_info.as_ref().unwrap();
match Auth::try_from(auth_info).unwrap() {
Auth::RefreshableToken(RefreshableToken::Exec(refreshable)) => {
Expand Down
14 changes: 4 additions & 10 deletions kube-client/src/config/file_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ impl Kubeconfig {

/// Read a Config from an arbitrary YAML string
///
/// This is preferable to using serde_yaml::from_str() because it will correctly
/// This is preferable to using serde_saphyr::from_str() because it will correctly
/// parse multi-document YAML text and merge them into a single `Kubeconfig`
pub fn from_yaml(text: &str) -> Result<Kubeconfig, KubeconfigError> {
kubeconfig_from_yaml(text)?
Expand Down Expand Up @@ -474,13 +474,7 @@ impl Kubeconfig {
}

fn kubeconfig_from_yaml(text: &str) -> Result<Vec<Kubeconfig>, KubeconfigError> {
let mut documents = vec![];
for doc in serde_yaml::Deserializer::from_str(text) {
let value = serde_yaml::Value::deserialize(doc).map_err(KubeconfigError::Parse)?;
let kubeconfig = serde_yaml::from_value(value).map_err(KubeconfigError::InvalidStructure)?;
documents.push(kubeconfig);
}
Ok(documents)
serde_saphyr::from_multiple(text).map_err(KubeconfigError::Parse)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems sensible and we are already changing the error type in a breaking way anyway here so if the old error falls away then that's probably ok.

}

#[allow(clippy::redundant_closure)]
Expand Down Expand Up @@ -934,7 +928,7 @@ users:
username: user
password:
"#;
let authinfo: AuthInfo = serde_yaml::from_str(authinfo_yaml).unwrap();
let authinfo: AuthInfo = serde_saphyr::from_str(authinfo_yaml).unwrap();
assert_eq!(authinfo.username, Some("user".to_string()));
assert!(authinfo.password.is_none());
}
Expand All @@ -945,7 +939,7 @@ password:
username: user
password: kube_rs
"#;
let authinfo: AuthInfo = serde_yaml::from_str(authinfo_yaml).unwrap();
let authinfo: AuthInfo = serde_saphyr::from_str(authinfo_yaml).unwrap();
let authinfo_debug_output = format!("{authinfo:?}");
let expected_output = "AuthInfo { \
username: Some(\"user\"), \
Expand Down
6 changes: 1 addition & 5 deletions kube-client/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,7 @@ pub enum KubeconfigError {

/// Failed to parse kubeconfig YAML
#[error("failed to parse kubeconfig YAML: {0}")]
Parse(#[source] serde_yaml::Error),

/// The structure of the parsed kubeconfig is invalid
#[error("the structure of the parsed kubeconfig is invalid: {0}")]
InvalidStructure(#[source] serde_yaml::Error),
Parse(#[source] serde_saphyr::Error),

/// Cluster url is missing on selected cluster
#[error("cluster url is missing on selected cluster")]
Expand Down