Skip to content

Commit bad84f6

Browse files
committed
Redo output
1 parent aebd97b commit bad84f6

9 files changed

Lines changed: 241 additions & 86 deletions

File tree

Cargo.lock

Lines changed: 79 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,5 @@ tokio-stream = { version = "0.1", features = ["io-util", "net"] }
1919
nix = { version= "0.31", features = ["sched"] }
2020
futures = "0.3"
2121
async-trait = "0.1"
22+
clap = { version = "4.5", features = ["derive"] }
23+
console = "0.16"

src/checkers/iommu.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use futures::{FutureExt, future::join_all};
88
use log::debug;
99
use std::path::Path;
1010

11-
const GROUP_IDENTIFIER: &str = "IOMMUChecks";
11+
const GROUP_IDENTIFIER: &str = "iommu";
1212
const NAME: &str = "IOMMU Checks";
1313

1414
pub struct IOMMUChecks {
@@ -26,7 +26,7 @@ impl IOMMUChecks {
2626
pub async fn run_all(&self) -> CheckGroupResult {
2727
let results = join_all([self.check_iommu().boxed()]).await;
2828

29-
let mut group_result = Skipped;
29+
let mut group_result = Passed;
3030
for res in results.iter() {
3131
// Set group result to Failed if we failed and aren't already in an Errored state
3232
if !matches!(group_result, Errored(_)) && matches!(res.result, Failed(_)) {

src/checkers/kernel.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use log::debug;
1111
use procfs::{Current, sys::kernel};
1212
use std::{fs, path::PathBuf, process::Command};
1313

14-
const GROUP_IDENTIFIER: &str = "KernelChecks";
14+
const GROUP_IDENTIFIER: &str = "kernel";
1515
const NAME: &str = "Kernel Checks";
1616
// TODO (bml) assemble actual list
1717
const REQUIRED_MODULES: &[&str] = &["nf_tables", "msr"];

src/checkers/pvh.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use std::{
1515
process::Command,
1616
};
1717

18-
const GROUP_IDENTIFIER: &str = "PVHChecks";
18+
const GROUP_IDENTIFIER: &str = "pvh";
1919
const NAME: &str = "PVH Checks";
2020

2121
#[derive(Debug, PartialEq)]
@@ -40,7 +40,7 @@ impl PVHChecks {
4040
pub async fn run_all(&self) -> CheckGroupResult {
4141
let results = join_all([self.check_virtualization().boxed()]).await;
4242

43-
let mut group_result = Skipped;
43+
let mut group_result = Passed;
4444
for res in results.iter() {
4545
// Set group result to Failed if we failed and aren't already in an Errored state
4646
if !matches!(group_result, Errored(_)) && matches!(res.result, Failed(_)) {

src/checkers/system.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use futures::{FutureExt, future::join_all};
99
use log::debug;
1010
use sysinfo::{Disks, System};
1111

12-
const GROUP_IDENTIFIER: &str = "SystemChecks";
12+
const GROUP_IDENTIFIER: &str = "system";
1313
const NAME: &str = "System Checks";
1414
const MINIMUM_MEMORY: u64 = 4 * 1024 * 1024 * 1024; // 4GB
1515
const MINIMUM_DISK: u64 = 20 * 1024 * 1024 * 1024; // 20GB

src/helpers/mod.rs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
pub mod host_executor;
22

3+
use console::{style, Emoji};
34
use async_trait::async_trait;
45
use log::{debug, error, info, warn};
56
use std::fmt;
67

8+
static CHECK: Emoji = Emoji("✅", "[+]");
9+
static WARN: Emoji = Emoji("⚠", "[!]");
10+
static ERROR: Emoji = Emoji("❌", "[X]");
11+
712
/// CheckResultValue is the final value for the result of an individual check.
813
///
914
/// Failed means a check ran successfully but did not pass. Errored means a check hit an
@@ -89,26 +94,25 @@ impl CheckGroupResult {
8994
pub fn log_group(&self) {
9095
let name = &self.name;
9196
let result = &self.result;
92-
let s = format!("[{}] {}", name, result);
97+
let s = format!("{}: {}", name, result);
9398
match result {
94-
CheckResultValue::Passed => info!("{}", s),
95-
CheckResultValue::Failed(_) => warn!("{}", s),
96-
CheckResultValue::Errored(_) => error!("{}", s),
97-
CheckResultValue::Skipped => debug!("{}", s),
99+
CheckResultValue::Passed => println!("{} {}", CHECK, style(s).green().bold()),
100+
CheckResultValue::Failed(_) => println!("{} {}",ERROR, style(s).bright().yellow().bold()),
101+
CheckResultValue::Errored(_) => println!("{} {}",ERROR, style(s).red().bright().bold()),
102+
CheckResultValue::Skipped => println!("{} {}",WARN, style(s).yellow().dim()),
98103
}
99104
}
100105

101106
/// log_individual_checks is a pretty-print helper to log the results of each individual check
102107
/// within a group.
103108
pub fn log_individual_checks(&self) {
104-
let group_name = &self.name;
105109
for check_result in self.results.iter() {
106110
let name = &check_result.name;
107111
let result = &check_result.result;
108-
let s = format!("[{}] {}: {}", group_name, name, result);
112+
let s = format!("{}: {}", name, result);
109113
match result {
110-
CheckResultValue::Passed => info!("{}", s),
111-
CheckResultValue::Failed(_) => warn!("{}", s),
114+
CheckResultValue::Passed => println!("{}", style(s).magenta().dim()),
115+
CheckResultValue::Failed(_) => println!("{}", s),
112116
CheckResultValue::Errored(_) => error!("{}", s),
113117
CheckResultValue::Skipped => debug!("{}", s),
114118
}

0 commit comments

Comments
 (0)