xianyun_cli/commands/
status.rs1use anyhow::Context as _;
6use clap::Args;
7use xianyun_cluster::driver::State;
8use xianyun_core::config::caproni::load_from_context;
9use xianyun_core::config::global::Context;
10
11#[derive(Args, Debug)]
12pub struct StatusArgs {}
13
14pub fn run(_args: &StatusArgs, ctx: &Context) -> anyhow::Result<()> {
15 run_status(ctx)
16}
17
18pub fn run_status(ctx: &Context) -> anyhow::Result<()> {
29 crate::drivers::ensure_registered();
30
31 let container = load_from_context(ctx).context("loading configuration")?;
32
33 let manager = xianyun_cluster::registry::new_manager(
34 container.caproni.cluster.clone(),
35 container.global.profile_name.clone(),
36 )
37 .context("creating cluster manager")?;
38
39 let status = manager.status().context("getting cluster status")?;
40
41 let reloader_count = container
42 .caproni
43 .reloaders
44 .as_ref()
45 .map_or(0, xianyun_core::orderedmap::OrderedMap::len);
46
47 if status.state != Some(State::Ready) || reloader_count == 0 {
48 return Ok(());
49 }
50
51 anyhow::bail!(
52 "reporting reloader status requires a real kubectl backend and reloader managers, \
53 neither of which is implemented in this worktree yet"
54 );
55}