From b3fcabbfd4620b23aa11ebc255b69a0dbef0cfce Mon Sep 17 00:00:00 2001 From: refcell Date: Thu, 27 Jun 2024 11:25:13 -0400 Subject: [PATCH] fix(examples): small cli fix (#323) --- examples/trusted-sync/src/cli.rs | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/examples/trusted-sync/src/cli.rs b/examples/trusted-sync/src/cli.rs index ed5e6c40e..597e660a6 100644 --- a/examples/trusted-sync/src/cli.rs +++ b/examples/trusted-sync/src/cli.rs @@ -36,12 +36,9 @@ pub struct Cli { /// The metrics server port. #[clap(long, help = "Port of the metrics server")] pub metrics_server_port: Option, - /// The address of the loki server. - #[clap(long, help = "Address of the loki server")] - pub loki_server_addr: Option, - /// The loki server port. - #[clap(long, help = "Port of the loki server")] - pub loki_server_port: Option, + /// The Loki Url endpoint. + #[clap(long, help = "Url to post Loki logs")] + pub loki_url: Option, } impl Cli { @@ -58,11 +55,10 @@ impl Cli { /// Returns the full loki server address. pub fn loki_addr(&self) -> Url { - let str = format!( - "http://{}:{}", - self.loki_server_addr.clone().unwrap_or_else(|| DEFAULT_LOKI_SERVER_ADDR.to_string()), - self.loki_server_port.unwrap_or(DEFAULT_LOKI_SERVER_PORT) - ); + if let Some(url) = self.loki_url.clone() { + return Url::parse(&url).expect("Failed to parse loki server address"); + } + let str = format!("http://{DEFAULT_LOKI_SERVER_ADDR}:{DEFAULT_LOKI_SERVER_PORT}"); Url::parse(&str).expect("Failed to parse loki server address") }