mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-04-30 12:44:39 +00:00
kata-ctl: clippy: Resolve warnings and reformat
Resolved a couple of clippy warnings and applied standard `rustfmt`. Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
This commit is contained in:
parent
133690434c
commit
c23584994a
@ -7,8 +7,8 @@
|
||||
pub use arch_specific::*;
|
||||
|
||||
mod arch_specific {
|
||||
use anyhow::{anyhow, Result};
|
||||
use crate::check;
|
||||
use anyhow::{anyhow, Result};
|
||||
|
||||
const PROC_CPUINFO: &str = "/proc/cpuinfo";
|
||||
const CPUINFO_DELIMITER: &str = "\nprocessor";
|
||||
@ -30,7 +30,10 @@ mod arch_specific {
|
||||
// TODO: Add more information to output (see kata-check in go tool); adjust formatting
|
||||
let missing_cpu_attributes = check::check_cpu_attribs(&cpu_info, CPU_ATTRIBS_INTEL)?;
|
||||
if missing_cpu_attributes.len() > 0 {
|
||||
eprintln!("WARNING: Missing CPU attributes {:?}", missing_cpu_attributes);
|
||||
eprintln!(
|
||||
"WARNING: Missing CPU attributes {:?}",
|
||||
missing_cpu_attributes
|
||||
);
|
||||
}
|
||||
let missing_cpu_flags = check::check_cpu_flags(&cpu_flags, CPU_FLAGS_INTEL)?;
|
||||
if missing_cpu_flags.len() > 0 {
|
||||
@ -40,7 +43,6 @@ mod arch_specific {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
pub fn check() -> Result<()> {
|
||||
println!("INFO: check: x86_64");
|
||||
|
||||
|
@ -3,11 +3,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
use clap::{
|
||||
Args,
|
||||
Parser,
|
||||
Subcommand
|
||||
};
|
||||
use clap::{Args, Parser, Subcommand};
|
||||
|
||||
use thiserror::Error;
|
||||
|
||||
|
@ -5,14 +5,14 @@
|
||||
|
||||
// Contains checks that are not architecture-specific
|
||||
|
||||
|
||||
use std::fs;
|
||||
use serde_json::Value;
|
||||
use std::collections::HashMap;
|
||||
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";
|
||||
const KATA_GITHUB_URL: &str =
|
||||
"https://api.github.com/repos/kata-containers/kata-containers/releases/latest";
|
||||
|
||||
fn get_cpu_info(cpu_info_file: &str) -> Result<String> {
|
||||
let contents = fs::read_to_string(cpu_info_file)?;
|
||||
@ -77,13 +77,19 @@ fn get_missing_strings(data: &str, required: &'static [&'static str]) -> Result<
|
||||
Ok(missing)
|
||||
}
|
||||
|
||||
pub fn check_cpu_flags(retrieved_flags: &str, required_flags: &'static [&'static str]) -> Result<Vec<String>> {
|
||||
pub fn check_cpu_flags(
|
||||
retrieved_flags: &str,
|
||||
required_flags: &'static [&'static str],
|
||||
) -> Result<Vec<String>> {
|
||||
let missing_flags = get_missing_strings(retrieved_flags, required_flags)?;
|
||||
|
||||
Ok(missing_flags)
|
||||
}
|
||||
|
||||
pub fn check_cpu_attribs(cpu_info: &str, required_attribs: &'static [&'static str]) -> Result<Vec<String>> {
|
||||
pub fn check_cpu_attribs(
|
||||
cpu_info: &str,
|
||||
required_attribs: &'static [&'static str],
|
||||
) -> Result<Vec<String>> {
|
||||
let mut cpu_info_processed = cpu_info.replace("\t", "");
|
||||
cpu_info_processed = cpu_info_processed.replace("\n", " ");
|
||||
|
||||
@ -146,7 +152,10 @@ mod tests {
|
||||
let actual = get_cpu_info("").err().unwrap().to_string();
|
||||
assert_eq!(expected, actual);
|
||||
|
||||
let actual = get_single_cpu_info("", "\nprocessor").err().unwrap().to_string();
|
||||
let actual = get_single_cpu_info("", "\nprocessor")
|
||||
.err()
|
||||
.unwrap()
|
||||
.to_string();
|
||||
assert_eq!(expected, actual);
|
||||
}
|
||||
|
||||
|
@ -3,33 +3,23 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
mod args;
|
||||
mod arch;
|
||||
mod args;
|
||||
mod check;
|
||||
mod ops;
|
||||
|
||||
use clap::Parser;
|
||||
use anyhow::Result;
|
||||
use clap::Parser;
|
||||
use std::process::exit;
|
||||
|
||||
use args::{
|
||||
KataCtlCli,
|
||||
Commands
|
||||
};
|
||||
use args::{Commands, KataCtlCli};
|
||||
|
||||
use ops::check_ops::{
|
||||
handle_check,
|
||||
handle_check_volume,
|
||||
handle_env,
|
||||
handle_exec,
|
||||
handle_factory,
|
||||
handle_iptables,
|
||||
handle_metrics,
|
||||
handle_version
|
||||
handle_check, handle_check_volume, handle_env, handle_exec, handle_factory, handle_iptables,
|
||||
handle_metrics, handle_version,
|
||||
};
|
||||
|
||||
fn real_main() -> Result<()> {
|
||||
|
||||
let args = KataCtlCli::parse();
|
||||
|
||||
match args.command {
|
||||
|
@ -7,12 +7,7 @@ use crate::arch;
|
||||
use crate::check;
|
||||
use crate::ops::version;
|
||||
|
||||
use crate::args::{
|
||||
CheckArgument,
|
||||
CheckSubCommand,
|
||||
IptablesCommand,
|
||||
MetricsCommand
|
||||
};
|
||||
use crate::args::{CheckArgument, CheckSubCommand, IptablesCommand, MetricsCommand};
|
||||
|
||||
use anyhow::Result;
|
||||
|
||||
@ -60,11 +55,11 @@ pub fn handle_factory() -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn handle_iptables(args: IptablesCommand) -> Result<()> {
|
||||
pub fn handle_iptables(_args: IptablesCommand) -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn handle_metrics(args: MetricsCommand) -> Result<()> {
|
||||
pub fn handle_metrics(_args: MetricsCommand) -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user