- CLI: add topology selection (-t/--topology), preview flags (--show/--report), and removable policy override (--allow-removable) (src/cli/args.rs) - Config: built-in sensible defaults; deterministic overlays for logging, fstab, removable, topology (src/config/loader.rs) - Device: discovery via /proc + /sys with include/exclude regex and removable policy (src/device/discovery.rs) - Idempotency: detection via blkid; safe emptiness checks (src/idempotency/mod.rs) - Partition: topology-driven planning (Single, DualIndependent, BtrfsRaid1, SsdHddBcachefs) (src/partition/plan.rs) - FS: planning + creation (mkfs.vfat, mkfs.btrfs, bcachefs format) and UUID capture via blkid (src/fs/plan.rs) - Orchestrator: pre-flight with preview JSON (disks, partition_plan, filesystems_planned, mount scheme). Skips emptiness in preview; supports stdout+file (src/orchestrator/run.rs) - Util/Logging/Types/Errors: process execution, tracing, shared types (src/util/mod.rs, src/logging/mod.rs, src/types.rs, src/errors.rs) - Docs: add README with exhaustive usage and preview JSON shape (README.md) Builds and unit tests pass: discovery, util, idempotency helpers, and fs parser tests.
57 lines
1.9 KiB
Rust
57 lines
1.9 KiB
Rust
// REGION: API
|
|
// api: binary::main() -> (process exit)
|
|
// api: binary::real_main() -> zosstorage::Result<()>
|
|
// REGION: API-END
|
|
//
|
|
// REGION: RESPONSIBILITIES
|
|
// - Minimal binary wrapper: parse CLI, init logging, load+validate config, run orchestrator.
|
|
// - Emit minimal fatal errors to stderr only; no stdout spam.
|
|
// Non-goals: business logic, module orchestration details (delegated to orchestrator).
|
|
// REGION: RESPONSIBILITIES-END
|
|
//
|
|
// REGION: EXTENSION_POINTS
|
|
// ext: add --version/--help output via clap (already provided by clap derive).
|
|
// ext: add build-info banner to logs when debug level (feature-gated).
|
|
// REGION: EXTENSION_POINTS-END
|
|
//
|
|
// REGION: SAFETY
|
|
// safety: never print secrets; errors are concise. Avoids panics; returns proper exit codes.
|
|
// REGION: SAFETY-END
|
|
//
|
|
// REGION: ERROR_MAPPING
|
|
// errmap: any failure bubbles as crate::Error via real_main() and is printed as a single-line stderr.
|
|
// REGION: ERROR_MAPPING-END
|
|
//
|
|
// REGION: TODO
|
|
// todo: add tracing spans around boot phases once logging init is implemented.
|
|
// REGION: TODO-END
|
|
//! Binary entrypoint for zosstorage.
|
|
//!
|
|
//! Initializes logging, parses CLI, loads/validates configuration,
|
|
//! and invokes the orchestrator run sequence. Avoids stdout spam.
|
|
|
|
use zosstorage::{Result, cli, config, logging, orchestrator};
|
|
|
|
fn main() {
|
|
if let Err(e) = real_main() {
|
|
// Minimal stderr emission permitted for fatal errors in initramfs.
|
|
eprintln!("error: {e}");
|
|
std::process::exit(1);
|
|
}
|
|
}
|
|
|
|
/// Orchestrates initialization steps and runs the provisioning flow.
|
|
fn real_main() -> Result<()> {
|
|
let cli = cli::from_args();
|
|
let log_opts = logging::LogOptions::from_cli(&cli);
|
|
logging::init_logging(&log_opts)?;
|
|
|
|
let cfg = config::load_and_merge(&cli)?;
|
|
config::validate(&cfg)?;
|
|
|
|
let ctx = orchestrator::Context::new(cfg, log_opts)
|
|
.with_show(cli.show)
|
|
.with_report_path(cli.report.clone());
|
|
orchestrator::run(&ctx)
|
|
}
|