You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/cli.rs
+44-18Lines changed: 44 additions & 18 deletions
Original file line number
Diff line number
Diff line change
@@ -295,6 +295,14 @@ pub struct Options {
295
295
)]
296
296
pubingestor_endpoint:String,
297
297
298
+
#[arg(
299
+
long,
300
+
env = "P_INDEXER_ENDPOINT",
301
+
default_value = "",
302
+
help = "URL to connect to this specific indexer. Default is the address of the server"
303
+
)]
304
+
pubindexer_endpoint:String,
305
+
298
306
#[command(flatten)]
299
307
puboidc:Option<OidcConfig>,
300
308
@@ -396,29 +404,47 @@ impl Options {
396
404
}
397
405
398
406
/// TODO: refactor and document
399
-
pubfnget_url(&self) -> Url{
400
-
ifself.ingestor_endpoint.is_empty(){
401
-
returnformat!(
402
-
"{}://{}",
403
-
self.get_scheme(),
404
-
self.address
405
-
)
406
-
.parse::<Url>()// if the value was improperly set, this will panic before hand
407
-
.unwrap_or_else(|err| {
408
-
panic!("{err}, failed to parse `{}` as Url. Please set the environment variable `P_ADDR` to `<ip address>:<port>` without the scheme (e.g., 192.168.1.1:8000). Please refer to the documentation: https://logg.ing/env for more details.",self.address)
409
-
});
410
-
}
411
-
412
-
let ingestor_endpoint = &self.ingestor_endpoint;
407
+
pubfnget_url(&self,mode:Mode) -> Url{
408
+
let(endpoint, env_var) = match mode {
409
+
Mode::Ingest => {
410
+
ifself.ingestor_endpoint.is_empty(){
411
+
returnformat!(
412
+
"{}://{}",
413
+
self.get_scheme(),
414
+
self.address
415
+
)
416
+
.parse::<Url>()// if the value was improperly set, this will panic before hand
417
+
.unwrap_or_else(|err| {
418
+
panic!("{err}, failed to parse `{}` as Url. Please set the environment variable `P_ADDR` to `<ip address>:<port>` without the scheme (e.g., 192.168.1.1:8000). Please refer to the documentation: https://logg.ing/env for more details.",self.address)
419
+
});
420
+
}
421
+
(&self.ingestor_endpoint,"P_INGESTOR_ENDPOINT")
422
+
}
423
+
Mode::Index => {
424
+
ifself.indexer_endpoint.is_empty(){
425
+
returnformat!(
426
+
"{}://{}",
427
+
self.get_scheme(),
428
+
self.address
429
+
)
430
+
.parse::<Url>()// if the value was improperly set, this will panic before hand
431
+
.unwrap_or_else(|err| {
432
+
panic!("{err}, failed to parse `{}` as Url. Please set the environment variable `P_ADDR` to `<ip address>:<port>` without the scheme (e.g., 192.168.1.1:8000). Please refer to the documentation: https://logg.ing/env for more details.",self.address)
433
+
});
434
+
}
435
+
(&self.indexer_endpoint,"P_INDEXER_ENDPOINT")
436
+
}
437
+
_ => panic!("Invalid mode"),
438
+
};
413
439
414
-
ifingestor_endpoint.starts_with("http"){
415
-
panic!("Invalid value `{}`, please set the environement variable `P_INGESTOR_ENDPOINT` to `<ip address / DNS>:<port>` without the scheme (e.g., 192.168.1.1:8000 or example.com:8000). Please refer to the documentation: https://logg.ing/env for more details.",ingestor_endpoint);
440
+
ifendpoint.starts_with("http"){
441
+
panic!("Invalid value `{}`, please set the environement variable `{env_var}` to `<ip address / DNS>:<port>` without the scheme (e.g., 192.168.1.1:8000 or example.com:8000). Please refer to the documentation: https://logg.ing/env for more details.",endpoint);
416
442
}
417
443
418
-
let addr_from_env = ingestor_endpoint.split(':').collect::<Vec<&str>>();
444
+
let addr_from_env = endpoint.split(':').collect::<Vec<&str>>();
419
445
420
446
if addr_from_env.len() != 2{
421
-
panic!("Invalid value `{}`, please set the environement variable `P_INGESTOR_ENDPOINT` to `<ip address / DNS>:<port>` without the scheme (e.g., 192.168.1.1:8000 or example.com:8000). Please refer to the documentation: https://logg.ing/env for more details.",ingestor_endpoint);
447
+
panic!("Invalid value `{}`, please set the environement variable `{env_var}` to `<ip address / DNS>:<port>` without the scheme (e.g., 192.168.1.1:8000 or example.com:8000). Please refer to the documentation: https://logg.ing/env for more details.",endpoint);
0 commit comments