topology: unify CLI and types::Topology (ValueEnum + aliases); bcachefs-2copy uses --replicas=2; update orchestrator call to make_filesystems(cfg); minor overlay fix; docs previously synced

This commit is contained in:
2025-09-29 22:56:23 +02:00
parent 2d43005b07
commit 7cef73368b
7 changed files with 57 additions and 41 deletions

View File

@@ -2,8 +2,21 @@
//!
//! Mirrors docs in [docs/SCHEMA.md](docs/SCHEMA.md) and is loaded/validated by
//! [fn load_and_merge()](src/config/loader.rs:1) and [fn validate()](src/config/loader.rs:1).
//
// REGION: API
// api: types::Topology { BtrfsSingle, BcachefsSingle, DualIndependent, Bcachefs2Copy, SsdHddBcachefs, BtrfsRaid1 }
// api: types::Config { logging, device_selection, topology, partitioning, filesystem, mount, report }
// api: types::Partitioning { alignment_mib, require_empty_disks, bios_boot, esp, data, cache }
// api: types::FsOptions { btrfs, bcachefs, vfat }
// REGION: API-END
//
// REGION: RESPONSIBILITIES
// - Define serde-serializable configuration types and enums used across modules.
// - Keep field names and enums stable; update docs/SCHEMA.md when public surface changes.
// REGION: RESPONSIBILITIES-END
use serde::{Deserialize, Serialize};
use clap::ValueEnum;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct LoggingConfig {
@@ -25,23 +38,44 @@ pub struct DeviceSelection {
pub min_size_gib: u64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[derive(Debug, Clone, Copy, Serialize, Deserialize, ValueEnum)]
#[serde(rename_all = "snake_case")]
#[value(rename_all = "snake_case")]
pub enum Topology {
/// Single eligible disk; btrfs on remainder.
#[value(alias = "btrfs-single")]
BtrfsSingle,
/// Single eligible disk; bcachefs on remainder.
#[value(alias = "bcachefs-single")]
BcachefsSingle,
/// Two eligible disks; independent btrfs on each data partition.
/// Independent btrfs filesystems on each data partition (any number of disks).
#[value(alias = "dual-independent")]
DualIndependent,
/// SSD + HDD; bcachefs with SSD cache/promote and HDD backing.
#[value(alias = "ssd-hdd-bcachefs")]
SsdHddBcachefs,
/// Two-disk bcachefs layout using both data partitions (2 copies semantics).
/// Multi-device bcachefs with two replicas (data+metadata).
#[value(alias = "bcachefs2-copy", alias = "bcachefs-2copy", alias = "bcachefs-2-copy")]
Bcachefs2Copy,
/// Optional mirrored btrfs across two disks when explicitly requested.
#[value(alias = "btrfs-raid1")]
BtrfsRaid1,
}
impl std::fmt::Display for Topology {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let s = match self {
Topology::BtrfsSingle => "btrfs_single",
Topology::BcachefsSingle => "bcachefs_single",
Topology::DualIndependent => "dual_independent",
Topology::SsdHddBcachefs => "ssd_hdd_bcachefs",
Topology::Bcachefs2Copy => "bcachefs2_copy",
Topology::BtrfsRaid1 => "btrfs_raid1",
};
f.write_str(s)
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct BiosBootSpec {
/// Whether to create a tiny BIOS boot partition.