//! Check K3s cluster status
//!
//! This example demonstrates how to check if K3s is installed
//! and get the cluster node status.
//!
//! Run with:
//! ```bash
//! cargo run --example cluster_status
//! ```

use lmrc_k3s::K3sManager;

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    // Initialize tracing for logs
    tracing_subscriber::fmt::init();

    let manager = K3sManager::builder().token("my-cluster-token").build();

    let master_ip = "192.168.1.10";

    // Check if K3s is installed
    println!("Checking if K3s is installed on {}...", master_ip);
    if manager.is_installed(master_ip).await? {
        println!("✓ K3s is installed");

        // Get node status
        println!("\nFetching cluster node status...");
        let nodes = manager.get_nodes(master_ip).await?;
        println!("Cluster nodes:\n{}", nodes);
    } else {
        println!("✗ K3s is not installed on this node");
    }

    Ok(())
}
