Skip to content

Commit b14f3d7

Browse files
authored
Merge pull request kube-rs#1840 from stackabletech/chore/remove-home-crate
chore: Remove dependency on home crate, use std instead
2 parents 1cae789 + f175bdc commit b14f3d7

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ either = "1.6.1"
4747
form_urlencoded = "1.2.0"
4848
futures = { version = "0.3.17", default-features = false }
4949
hashbrown = "0.16.0"
50-
home = "0.5.4"
5150
hostname = "0.4"
5251
http = "1.1.0"
5352
http-body = "1.0.1"

kube-client/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ gzip = ["client", "tower-http/decompression-gzip"]
2626
client = ["config", "__non_core", "hyper", "hyper-util", "http-body", "http-body-util", "tower", "tower-http", "hyper-timeout", "chrono", "jsonpath-rust", "bytes", "futures", "tokio", "tokio-util", "either"]
2727
jsonpatch = ["kube-core/jsonpatch"]
2828
admission = ["kube-core/admission"]
29-
config = ["__non_core", "pem", "home"]
29+
config = ["__non_core", "pem"]
3030
socks5 = ["hyper-util/client-proxy"]
3131
http-proxy = ["hyper-util/client-proxy"]
3232
unstable-client = []
@@ -45,7 +45,6 @@ workspace = true
4545
[dependencies]
4646
base64 = { workspace = true, optional = true }
4747
chrono = { workspace = true, optional = true }
48-
home = { workspace = true, optional = true }
4948
serde = { workspace = true, features = ["derive"] }
5049
serde_json.workspace = true
5150
serde_yaml = { workspace = true, optional = true }

kube-client/src/config/file_config.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,15 @@ fn ensure_trailing_newline(mut data: Vec<u8>) -> Vec<u8> {
660660

661661
/// Returns kubeconfig path from `$HOME/.kube/config`.
662662
fn default_kube_path() -> Option<PathBuf> {
663-
home::home_dir().map(|h| h.join(".kube").join("config"))
663+
// Before Rust 1.85.0, `home_dir` would return wrong results on Windows, usage of the crate
664+
// `home` was encouraged (and is what kube-rs did).
665+
// Rust 1.85.0 fixed the problem (https://doc.rust-lang.org/1.85.0/std/env/fn.home_dir.html),
666+
// Rust 1.87.0 removed the function deprecation.
667+
// As the MSRV was bumped to 1.85.0 we are safe to use the fixed std function.
668+
// Note: We intentionally use `allow` over `expect` to support compilation on Rust >= 1.87.0
669+
// Note: This can be removed once the MSRV is bumped to >= 1.87.0
670+
#[allow(deprecated)]
671+
std::env::home_dir().map(|h| h.join(".kube").join("config"))
664672
}
665673

666674
mod base64serde {

0 commit comments

Comments
 (0)