From de7eda2dc6a6dbad3c3ec96e71673c5a8a48bb79 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Wed, 1 Jun 2022 23:23:35 +0300 Subject: [PATCH] Fix url path printing --- control_plane/src/local_env.rs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/control_plane/src/local_env.rs b/control_plane/src/local_env.rs index 2623f65242..f7bb890893 100644 --- a/control_plane/src/local_env.rs +++ b/control_plane/src/local_env.rs @@ -119,16 +119,24 @@ impl EtcdBroker { } pub fn comma_separated_endpoints(&self) -> String { - self.broker_endpoints.iter().map(Url::as_str).fold( - String::new(), - |mut comma_separated_urls, url| { + self.broker_endpoints + .iter() + .map(|url| { + // URL by default adds a '/' path at the end, which is not what etcd CLI wants. + let url_string = url.as_str(); + if url_string.ends_with('/') { + &url_string[0..url_string.len() - 1] + } else { + url_string + } + }) + .fold(String::new(), |mut comma_separated_urls, url| { if !comma_separated_urls.is_empty() { comma_separated_urls.push(','); } comma_separated_urls.push_str(url); comma_separated_urls - }, - ) + }) } }