xianyun_cli/commands/
destroy.rs1use anyhow::Context as _;
6use clap::Args;
7use xianyun_core::config::caproni::load_from_context;
8use xianyun_core::config::global::Context;
9
10#[derive(Args, Debug)]
11pub struct DestroyArgs {}
12
13pub fn run(_args: &DestroyArgs, ctx: &Context) -> anyhow::Result<()> {
14 run_destroy(ctx)
15}
16
17pub fn run_destroy(ctx: &Context) -> anyhow::Result<()> {
22 crate::drivers::ensure_registered();
23
24 let container = load_from_context(ctx).context("loading configuration")?;
25
26 let manager = xianyun_cluster::registry::new_manager(
27 container.caproni.cluster.clone(),
28 container.global.profile_name.clone(),
29 )
30 .context("creating cluster manager")?;
31
32 manager.destroy().context("destroying cluster")?;
33
34 if let Err(err) =
37 xianyun_deploy::registrycache::ensure_stopped_for_profile(&container.global.profile_name)
38 {
39 tracing::warn!(
40 profile = %container.global.profile_name,
41 error = %err,
42 "could not release registry cache ref"
43 );
44 }
45
46 Ok(())
47}