apply mode: wire partition apply + mkfs; btrfs RAID1 flags and -f; UEFI detection and skip bios_boot when UEFI; sgdisk-based partition apply; update TODO and REGION markers
This commit is contained in:
@@ -48,6 +48,7 @@ use crate::{
|
||||
device::{discover, DeviceFilter, Disk},
|
||||
idempotency,
|
||||
partition,
|
||||
fs as zfs,
|
||||
Error, Result,
|
||||
};
|
||||
use humantime::format_rfc3339;
|
||||
@@ -66,6 +67,8 @@ pub struct Context {
|
||||
pub log: LogOptions,
|
||||
/// When true, print detection and planning summary to stdout (JSON).
|
||||
pub show: bool,
|
||||
/// When true, perform destructive actions (apply mode).
|
||||
pub apply: bool,
|
||||
/// Optional report path override (when provided by CLI --report).
|
||||
pub report_path_override: Option<String>,
|
||||
}
|
||||
@@ -77,6 +80,7 @@ impl Context {
|
||||
cfg,
|
||||
log,
|
||||
show: false,
|
||||
apply: false,
|
||||
report_path_override: None,
|
||||
}
|
||||
}
|
||||
@@ -93,6 +97,16 @@ impl Context {
|
||||
self
|
||||
}
|
||||
|
||||
/// Enable or disable apply mode (destructive).
|
||||
///
|
||||
/// When set to true (e.g. via `--apply`), orchestrator:
|
||||
/// - Enforces empty-disk policy (unless disabled in config)
|
||||
/// - Applies partition plan, then (future) mkfs, mounts, and report
|
||||
pub fn with_apply(mut self, apply: bool) -> Self {
|
||||
self.apply = apply;
|
||||
self
|
||||
}
|
||||
|
||||
/// Override the report output path used by preview mode.
|
||||
///
|
||||
/// When provided (e.g. via `--report /path/file.json`), orchestrator:
|
||||
@@ -171,11 +185,27 @@ pub fn run(ctx: &Context) -> Result<()> {
|
||||
debug!("plan for {}: {} part(s)", dp.disk.path, dp.parts.len());
|
||||
}
|
||||
|
||||
// Note:
|
||||
// - Applying partitions, creating filesystems, mounting, and reporting
|
||||
// will be wired in subsequent steps. For now this performs pre-flight
|
||||
// checks and planning to exercise real code paths safely.
|
||||
// Apply mode: perform destructive partition application now.
|
||||
if ctx.apply {
|
||||
info!("orchestrator: apply mode enabled; applying partition plan");
|
||||
let part_results = partition::apply_partitions(&plan)?;
|
||||
info!(
|
||||
"orchestrator: applied partitions on {} disk(s), total parts created: {}",
|
||||
plan.disks.len(),
|
||||
part_results.len()
|
||||
);
|
||||
|
||||
// Filesystem planning and creation
|
||||
let fs_plan = zfs::plan_filesystems(&part_results, &ctx.cfg)?;
|
||||
info!("orchestrator: filesystem plan contains {} spec(s)", fs_plan.specs.len());
|
||||
let fs_results = zfs::make_filesystems(&fs_plan)?;
|
||||
info!("orchestrator: created {} filesystem(s)", fs_results.len());
|
||||
|
||||
// Next steps (mounts, optional fstab, state report) will be wired in follow-ups.
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
// Preview-only path
|
||||
info!("orchestrator: pre-flight complete (idempotency checked, devices discovered, plan computed)");
|
||||
|
||||
// Optional: emit JSON summary via --show or write via --report
|
||||
|
||||
Reference in New Issue
Block a user