1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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)
}