~ knotless Search/
↑↓ move↵ open⇧↵ all results

johnandersen777.bsky.social/asyncai

0
0
main
32 lines · 1.1 KB Raw History
use clap::Parser;

use super::runner::Runner;
use super::service::KcpService;

#[derive(Clone, Debug, Parser)]
#[command(about = "Interact with running socialweb-computer kcp servers")]
pub struct ServerArgs {
    /// Run every command through this SSH host, for example "hat-7".
    #[arg(long)]
    pub ssh: Option<String>,
    /// Prefix kubectl, find, and shell commands with "sudo -n".
    #[arg(long)]
    pub sudo: bool,
    /// kubectl executable name or path.
    #[arg(long)]
    pub kubectl: Option<String>,
    /// State root to search for kcp admin kubeconfigs. Repeatable.
    #[arg(long = "root", action = clap::ArgAction::Append)]
    pub roots: Vec<String>,
    /// Explicit admin kubeconfig. Repeatable. Disables root discovery when set.
    #[arg(long = "kubeconfig", action = clap::ArgAction::Append)]
    pub kubeconfigs: Vec<String>,
    /// Allow operations on protected production hosts.
    #[arg(long)]
    pub allow_prod: bool,
}

pub fn service_from_args(args: ServerArgs) -> KcpService {
    let runner = Runner::new(args.ssh, args.sudo, args.kubectl);
    KcpService::new(runner, args.roots, args.kubeconfigs, args.allow_prod)
}