From b324ed5dc6921d6c4dd0c238932b6ef61639975e Mon Sep 17 00:00:00 2001 From: onalante-msft <89409054+onalante-msft@users.noreply.github.com> Date: Thu, 6 Jan 2022 10:29:46 -0800 Subject: [PATCH] Unify nix dependency and remove unnecessary clone --- Cargo.lock | 4 ++-- aziotctl/Cargo.toml | 2 +- aziotctl/aziotctl-common/Cargo.toml | 2 +- aziotctl/aziotctl-common/src/host_info.rs | 18 +++++++----------- http-common/Cargo.toml | 2 +- 5 files changed, 12 insertions(+), 16 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1d2635323..f5603e4ae 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1719,9 +1719,9 @@ dependencies = [ [[package]] name = "nix" -version = "0.22.2" +version = "0.23.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3bb9a13fa32bc5aeb64150cd3f32d6cf4c748f8f8a417cce5d2eb976a8370ba" +checksum = "9f866317acbd3a240710c63f065ffb1e4fd466259045ccb504130b7f668f35c6" dependencies = [ "bitflags", "cc", diff --git a/aziotctl/Cargo.toml b/aziotctl/Cargo.toml index c041a861b..719b28440 100644 --- a/aziotctl/Cargo.toml +++ b/aziotctl/Cargo.toml @@ -18,7 +18,7 @@ foreign-types-shared = "0.1" hyper = "0.14" hyper-openssl = "0.9" libc = "0.2" -nix = "0.22" +nix = "0.23" log = "0.4" openssl = "0.10" serde = { version = "1", features = ["derive"] } diff --git a/aziotctl/aziotctl-common/Cargo.toml b/aziotctl/aziotctl-common/Cargo.toml index ff68a6fd6..d1fd326de 100644 --- a/aziotctl/aziotctl-common/Cargo.toml +++ b/aziotctl/aziotctl-common/Cargo.toml @@ -9,7 +9,7 @@ edition = "2021" anyhow = "1.0.34" base64 = "0.13" log = "0.4" -nix = "0.22" +nix = "0.23" serde = { version = "1", features = ["derive"] } serde_json = "1" serde_with = "1" diff --git a/aziotctl/aziotctl-common/src/host_info.rs b/aziotctl/aziotctl-common/src/host_info.rs index f95292071..13b7f977a 100644 --- a/aziotctl/aziotctl-common/src/host_info.rs +++ b/aziotctl/aziotctl-common/src/host_info.rs @@ -82,8 +82,8 @@ impl Default for OsInfo { bitness: BITNESS, }; - let os_release = fs::File::open("/etc/os-release") - .or_else(|_| fs::File::open("/usr/lib/os-release")); + let os_release = + fs::File::open("/etc/os-release").or_else(|_| fs::File::open("/usr/lib/os-release")); if let Ok(os_release) = os_release { let os_release = io::BufReader::new(os_release); @@ -93,17 +93,16 @@ impl Default for OsInfo { match parse_shell_line(line) { Some(("ID", value)) => { result.id = Some(value.to_owned()); - }, + } Some(("VERSION_ID", value)) => { result.version_id = Some(value.to_owned()); - }, + } Some(("PRETTY_NAME", value)) => { result.pretty_name = Some(value.to_owned()); - }, + } _ => (), }; - } - else { + } else { break; } } @@ -138,8 +137,5 @@ fn try_read_dmi(entry: &'static str) -> Option { let bytes = fs::read(path).ok()?; - Some(String::from_utf8(bytes) - .ok()? - .trim() - .to_owned()) + Some(std::str::from_utf8(&bytes).ok()?.trim().to_owned()) } diff --git a/http-common/Cargo.toml b/http-common/Cargo.toml index 56eea54a1..0c7fa52ff 100644 --- a/http-common/Cargo.toml +++ b/http-common/Cargo.toml @@ -15,7 +15,7 @@ hyper-openssl = { version = "0.9" } hyper-proxy = { version = "0.9", features = ["openssl-tls"], default-features = false } libc = "0.2" log = "0.4" -nix = "0.22" +nix = "0.23" openssl = { version = "0.10" } openssl-sys = { version = "0.9" } percent-encoding = "2"