Skip to content

Commit a45293f

Browse files
committed
feat: allow skipping groups and add readme
Signed-off-by: James Petersen <jpetersenames@gmail.com>
1 parent aecd60a commit a45293f

2 files changed

Lines changed: 74 additions & 3 deletions

File tree

README.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Preflight CLI
2+
3+
Internal CLI to run **pre-deployment checks** before running workloads.
4+
Checks are organized into groups (e.g., `System Checks`, `Scripted Checks`) and controlled via environment variables.
5+
6+
---
7+
8+
## Usage
9+
10+
Run inside Docker:
11+
12+
```bash
13+
docker run \
14+
--env RUST_LOG=debug \
15+
--env EDERA_PREFLIGHT_VERBOSE=true \
16+
--env EDERA_PREFLIGHT_SKIP_GROUPS='ScriptedChecks;SystemChecks' \
17+
--env EDERA_PREFLIGHT_SCRIPTS_DIR=/scripts \
18+
<image>
19+
```
20+
21+
---
22+
23+
## Environment Variables
24+
25+
| Variable | Description | Example |
26+
| ----------------------------- | ------------------------------------------------------ | ----------------------------- |
27+
| `RUST_LOG` | Log level (`error`, `warn`, `info`, `debug`, `trace`). | `debug` |
28+
| `EDERA_PREFLIGHT_VERBOSE` | Enable verbose output (`true`/`false`). | `true` |
29+
| `EDERA_PREFLIGHT_SKIP_GROUPS` | Semicolon-separated list of groups to skip. | `SystemChecks;ScriptedChecks` |
30+
| `EDERA_PREFLIGHT_SCRIPTS_DIR` | Directory containing custom shell-script checks. | `/scripts` |
31+
32+
---
33+
34+
## Example Output
35+
36+
```text
37+
[2025-09-17T05:05:33Z INFO preflight] Running Group [System Checks] - System requirement checks
38+
[2025-09-17T05:05:33Z DEBUG preflight::system] total memory = 66617298944
39+
[2025-09-17T05:05:33Z ERROR preflight] [System Checks] Errored: group errored
40+
[2025-09-17T05:05:33Z INFO preflight] [System Checks] Enough Memory: Passed
41+
[2025-09-17T05:05:33Z ERROR preflight] [System Checks] Should Error: Errored: Pretending to error
42+
[2025-09-17T05:05:33Z WARN preflight] [System Checks] Should Fail: Failed: Pretending to fail
43+
[2025-09-17T05:05:33Z INFO preflight] Running Group [Scripted Checks] - Checks composed through small shell scripts
44+
[2025-09-17T05:05:33Z ERROR preflight] [Scripted Checks] Errored: group errored
45+
[2025-09-17T05:05:33Z INFO preflight] [Scripted Checks] Should Pass: Passed
46+
[2025-09-17T05:05:33Z WARN preflight] [Scripted Checks] Should Fail: Failed: script returned Some(1)
47+
[2025-09-17T05:05:33Z ERROR preflight] [Scripted Checks] /totally/fake/script: Errored: No such file or directory (os error 2)
48+
Error: checks failed
49+
```
50+
51+
* **INFO** → check passed or group started
52+
* **WARN** → check failed
53+
* **ERROR** → check errored or group errored
54+
55+
Exit code is **non-zero** if any check/group fails or errors.
56+
57+
---
58+
59+
## Notes
60+
61+
* Use `EDERA_PREFLIGHT_SKIP_GROUPS` to bypass slow or irrelevant checks.
62+
* Script-based checks must be **executable** and located in `EDERA_PREFLIGHT_SCRIPTS_DIR`.

src/main.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,27 @@ use anyhow::{Result, bail};
99
use log::info;
1010
use std::env;
1111

12+
// Skip certain groups. List is separated by ;
13+
fn skip_groups() -> Vec<String> {
14+
let skips = env::var("EDERA_PREFLIGHT_SKIP_GROUPS").unwrap_or_default();
15+
skips.split(";").map(|s| s.to_string()).collect()
16+
}
17+
1218
fn main() -> Result<()> {
1319
env_logger::init();
1420

1521
let groups: Vec<Box<dyn CheckGroup>> = vec![Box::new(SystemChecks), Box::new(ScriptChecks)];
1622

1723
let mut final_result = Passed;
24+
let skip_groups = skip_groups();
1825

1926
// Run each check group
2027
for group in groups {
21-
// if group.id() == "ScriptedChecks" {
22-
// continue;
23-
// }
28+
// Check if we need to explicity skip this group
29+
if skip_groups.iter().any(|skip| group.id() == skip) {
30+
continue;
31+
}
32+
2433
info!("Running Group [{}] - {}", group.name(), group.description());
2534
let check_group_result = group.run();
2635
check_group_result.log_group();

0 commit comments

Comments
 (0)