mirror of
https://github.com/edera-dev/krata.git
synced 2025-08-02 21:00:55 +00:00
* chore(code): simple code cleanup * chore(code): additional code cleanup * feature(krata): rework api and make ip assignment persistent to database * rework and cleanup * fix daemon config references
30 lines
805 B
Rust
30 lines
805 B
Rust
use anyhow::Result;
|
|
use clap::Parser;
|
|
use krata::v1::control::{control_service_client::ControlServiceClient, ResolveZoneIdRequest};
|
|
|
|
use tonic::{transport::Channel, Request};
|
|
|
|
#[derive(Parser)]
|
|
#[command(about = "Resolve a zone name to a uuid")]
|
|
pub struct ZoneResolveCommand {
|
|
#[arg(help = "Zone name")]
|
|
zone: String,
|
|
}
|
|
|
|
impl ZoneResolveCommand {
|
|
pub async fn run(self, mut client: ControlServiceClient<Channel>) -> Result<()> {
|
|
let reply = client
|
|
.resolve_zone_id(Request::new(ResolveZoneIdRequest {
|
|
name: self.zone.clone(),
|
|
}))
|
|
.await?
|
|
.into_inner();
|
|
if !reply.zone_id.is_empty() {
|
|
println!("{}", reply.zone_id);
|
|
} else {
|
|
std::process::exit(1);
|
|
}
|
|
Ok(())
|
|
}
|
|
}
|