diff options
| author | tv <tv@krebsco.de> | 2026-11-30 17:56:39 +0000 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-11-30 19:51:09 +0000 |
| commit | 62f857e35f94e98b3205502e410f0d727fa5ecc5 (patch) | |
| tree | 9f1197abecef97948480d710cfa4b01ad0dacf47 /src/main.rs | |
| parent | 94c73688f08dd4a6bb25c75e62cdaf7849f6c0a1 (diff) | |
enstate: --stage, a submission for the next generation
Plans against --schema, stores the snapshot under it, and puts no views
in place and runs no reactions: the running generation goes on as it
is, keeping what it has no slot for, and the switch (--migrate) brings
the new views. The way to fill a required slot a generation adds before
switching to it, and to bring a host's first state: with the new
system's enstate, schema and configuration. Tests, and a subtest of the
VM test that does so.
Diffstat (limited to 'src/main.rs')
| -rw-r--r-- | src/main.rs | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/src/main.rs b/src/main.rs index 12db84b..df8b5c0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -78,6 +78,10 @@ const COMMANDS: &[(&str, &str)] = &[ "apply", "Apply the submission in PATH, if its plan is accepted", ), + ( + "stage", + "Like --apply, for the generation of --schema before switching to it: the snapshot only, no views, no reactions", + ), ("status", "Show the channels' snapshots and the views"), ( "materialize", @@ -126,7 +130,7 @@ fn command() -> Command { Arg::new("json") .long("json") .action(ArgAction::SetTrue) - .help("Print JSON (--plan, --apply, --status, --materialize, --migrate)"), + .help("Print JSON (--plan, --apply, --stage, --status, --materialize, --migrate)"), ) .arg( Arg::new("dry-run") @@ -143,7 +147,7 @@ fn command() -> Command { .arg( Arg::new("path") .value_name("PATH") - .help("The submission (--plan, --apply) or source list (--pack)"), + .help("The submission (--plan, --apply, --stage) or source list (--pack)"), ) .next_help_heading("Settings"); config::arguments::with_print_config(config::arguments::with_options(command, OPTIONS)) @@ -199,7 +203,7 @@ fn run() -> Result<ExitCode> { let path = matches.get_one::<String>("path").map(PathBuf::from); let out = matches.get_one::<String>("out").map(PathBuf::from); // An option that isn't for the command is an error. - let takes_path = matches!(command, "plan" | "apply" | "pack"); + let takes_path = matches!(command, "plan" | "apply" | "stage" | "pack"); match (&path, takes_path) { (None, true) => bail!("--{command} needs a PATH"), (Some(path), false) => bail!("--{command} takes no PATH ({})", path.display()), @@ -242,18 +246,20 @@ fn run() -> Result<ExitCode> { .unwrap_or_else(|| PathBuf::from("systemctl")); let lock = store.lock()?; match command { - "plan" | "apply" => { + "plan" | "apply" | "stage" => { let submission = Submission::load(path.as_deref().unwrap())?; let planned = plan::plan(&schema, &store, &submission)?; let plan = if command == "apply" { planned.apply(&store, &schema_bytes, &systemctl, lock)? + } else if command == "stage" { + planned.stage(&store, &schema_bytes, lock)? } else { planned.plan }; if json { println!("{}", serde_json::to_string_pretty(&plan)?); } else { - print_plan(&plan, command == "apply")?; + print_plan(&plan, command != "plan")?; } Ok(if !plan.accepted { ExitCode::from(1) @@ -388,8 +394,14 @@ fn print_plan(plan: &Plan, applying: bool) -> Result<()> { } if applying && plan.accepted { match &plan.snapshot { + Some(id) if plan.staged => writeln!( + out, + "staged: snapshot {id}; views and reactions come with the switch" + )?, Some(id) => writeln!(out, "applied: snapshot {id}")?, - None if plan.changes => writeln!(out, "applied: the snapshot is unchanged")?, + None if plan.changes && !plan.staged => { + writeln!(out, "applied: the snapshot is unchanged")? + } None => {} } for failed in &plan.failed { |
