summaryrefslogtreecommitdiffstats
path: root/src/config/mod.rs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-10-25 13:39:44 +0100
committertv <tv@krebsco.de>2026-10-25 13:39:44 +0100
commit714debc94b0ef2b543949241f1eb04ae5738ad0c (patch)
tree975232c77d5e7be54853555afafc4ed3ab1c8d11 /src/config/mod.rs
parentf52ae6973299fa3c1d81758838951e39904e1d84 (diff)
add force module usable by API and CLI
Diffstat (limited to 'src/config/mod.rs')
-rw-r--r--src/config/mod.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/config/mod.rs b/src/config/mod.rs
index 0771e7e..c83ca70 100644
--- a/src/config/mod.rs
+++ b/src/config/mod.rs
@@ -65,6 +65,9 @@ const fn option(
}
}
+/// What `--force` may override at start (`force`).
+pub(crate) const FORCE: &[&str] = &["swarmId"];
+
/// Every option. Names are the long option names and the configuration file keys.
pub(crate) const OPTIONS: &[OptionSpec] = &[
option(
@@ -110,6 +113,13 @@ pub(crate) const OPTIONS: &[OptionSpec] = &[
"Start a new swarm, as its genesis node, instead of joining one through seeds. Every start with it starts another new swarm: drop it once the swarm exists, and give the node seeds instead. Can't be combined with seeds. With a --state-file that remembers a swarm, it starts that swarm again instead (empty; nodes of it still running merge with this one).",
),
option(
+ "force",
+ Kind::List,
+ "NAME,[NAME...]",
+ None,
+ "Override checks that otherwise refuse to start: true for all, or names: swarmId (a backup of another swarm than the state file remembers).",
+ ),
+ option(
"recover-from",
Kind::Text,
"PATH",
@@ -238,6 +248,8 @@ pub(crate) struct Settings {
pub(crate) genesis: bool,
pub(crate) state_file: Option<PathBuf>,
pub(crate) recover_from: Option<PathBuf>,
+ #[serde(default)]
+ pub(crate) force: Vec<String>,
pub(crate) swarm_key_file: Option<PathBuf>,
pub(crate) alias: Option<String>,
#[serde(default = "default_keepalive_secs")]
@@ -311,6 +323,8 @@ impl Settings {
);
}
}
+ crate::force::Force::parse(self.force.iter().map(String::as_str), FORCE)
+ .map_err(|reason| anyhow!("force: {reason}"))?;
// Contradictions, not overrides: an error wherever the options come from.
if self.genesis && !self.seeds.is_empty() {
bail!(