diff --git a/src/tools/kata-ctl/Cargo.toml b/src/tools/kata-ctl/Cargo.toml index 094613c34389..04b177b002e4 100644 --- a/src/tools/kata-ctl/Cargo.toml +++ b/src/tools/kata-ctl/Cargo.toml @@ -3,6 +3,9 @@ # SPDX-License-Identifier: Apache-2.0 # +[workspace] +resolver = "2" + [package] name = "kata-ctl" version = "0.0.1" @@ -12,9 +15,14 @@ edition = "2018" [dependencies] anyhow = "1.0.31" clap = { version = "3.2.20", features = ["derive", "cargo"] } -reqwest = { version = "0.11", default-features = false, features = ["json", "blocking", "rustls-tls"] } serde_json = "1.0.85" thiserror = "1.0.35" +[target.'cfg(target_arch = "s390x")'.dependencies] +reqwest = { version = "0.11", default-features = false, features = ["json", "blocking", "native-tls"] } + +[target.'cfg(not(target_arch = "s390x"))'.dependencies] +reqwest = { version = "0.11", default-features = false, features = ["json", "blocking", "rustls-tls"] } + [dev-dependencies] semver = "1.0.12" diff --git a/src/tools/kata-ctl/src/check.rs b/src/tools/kata-ctl/src/check.rs index 28febb307c25..c3fe620f7011 100644 --- a/src/tools/kata-ctl/src/check.rs +++ b/src/tools/kata-ctl/src/check.rs @@ -9,18 +9,23 @@ use anyhow::{anyhow, Result}; use reqwest::header::{CONTENT_TYPE, USER_AGENT}; use serde_json::Value; use std::collections::HashMap; -use std::fs; const KATA_GITHUB_URL: &str = "https://api.github.com/repos/kata-containers/kata-containers/releases/latest"; +#[cfg(any( + target_arch = "x86_64" +))] fn get_cpu_info(cpu_info_file: &str) -> Result { - let contents = fs::read_to_string(cpu_info_file)?; + let contents = std::fs::read_to_string(cpu_info_file)?; Ok(contents) } // get_single_cpu_info returns the contents of the first cpu from // the specified cpuinfo file by parsing based on a specified delimiter +#[cfg(any( + target_arch = "x86_64" +))] pub fn get_single_cpu_info(cpu_info_file: &str, substring: &str) -> Result { let contents = get_cpu_info(cpu_info_file)?; @@ -40,6 +45,9 @@ pub fn get_single_cpu_info(cpu_info_file: &str, substring: &str) -> Result Result { if cpu_info.is_empty() { return Err(anyhow!("cpu_info string is empty"))?; @@ -63,6 +71,9 @@ pub fn get_cpu_flags(cpu_info: &str, cpu_flags_tag: &str) -> Result { // get_missing_strings searches for required (strings) in data and returns // a vector containing the missing strings +#[cfg(any( + target_arch = "x86_64" +))] fn get_missing_strings(data: &str, required: &'static [&'static str]) -> Result> { let mut missing: Vec = Vec::new(); @@ -75,6 +86,9 @@ fn get_missing_strings(data: &str, required: &'static [&'static str]) -> Result< Ok(missing) } +#[cfg(any( + target_arch = "x86_64" +))] pub fn check_cpu_flags( retrieved_flags: &str, required_flags: &'static [&'static str], @@ -84,6 +98,9 @@ pub fn check_cpu_flags( Ok(missing_flags) } +#[cfg(any( + target_arch = "x86_64" +))] pub fn check_cpu_attribs( cpu_info: &str, required_attribs: &'static [&'static str], @@ -139,6 +156,9 @@ pub fn check_version() -> Result<()> { Ok(()) } +#[cfg(any( + target_arch = "x86_64" +))] #[cfg(test)] mod tests { use super::*;