1use crate::config::Config;
4use anyhow::Result;
5
6pub async fn handle_recover_approved(config: &Config, yes: bool) -> Result<()> {
7 let reviewed = crate::lifecycle_plan::review_plans(
8 config,
9 [crate::lifecycle_plan::LifecyclePlanRequest::sys_recovery()],
10 yes,
11 )
12 .await?
13 .into_iter()
14 .next()
15 .expect("one reviewed Sys recovery Plan");
16 let runtime = crate::lifecycle_plan::prepare_runtime(config, &reviewed).await?;
17 let report = match crate::lifecycle_plan::execute_reviewed(
18 config,
19 runtime,
20 reviewed,
21 shine_core::frontend::ExecutionOptions::default(),
22 &mut shine_core::runtime::NullObserver,
23 &mut crate::presentation::TerminalInteraction,
24 )
25 .await?
26 {
27 shine_core::frontend::OperationDetails::SysRecovery(report) => *report,
28 _ => unreachable!("reviewed operation result type"),
29 };
30 if report.rolled_back_actions.is_empty() {
31 println!(
32 "Sys recovery complete: cleared the committed operation journal; no managed resource was rolled back."
33 );
34 } else {
35 println!(
36 "Sys recovery complete: rolled back {} interrupted managed resource action(s) and cleared the operation journal.",
37 report.rolled_back_actions.len()
38 );
39 }
40 Ok(())
41}