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-18
Original file line number
Diff line number
Diff line change
@@ -294,6 +294,14 @@ pub struct Options {
294
294
)]
295
295
pubingestor_endpoint:String,
296
296
297
+
#[arg(
298
+
long,
299
+
env = "P_IDEXER_ENDPOINT",
300
+
default_value = "",
301
+
help = "URL to connect to this specific indexer. Default is the address of the server"
302
+
)]
303
+
pubindexer_endpoint:String,
304
+
297
305
#[command(flatten)]
298
306
puboidc:Option<OidcConfig>,
299
307
@@ -395,29 +403,47 @@ impl Options {
395
403
}
396
404
397
405
/// TODO: refactor and document
398
-
pubfnget_url(&self) -> Url{
399
-
ifself.ingestor_endpoint.is_empty(){
400
-
returnformat!(
401
-
"{}://{}",
402
-
self.get_scheme(),
403
-
self.address
404
-
)
405
-
.parse::<Url>()// if the value was improperly set, this will panic before hand
406
-
.unwrap_or_else(|err| {
407
-
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)
408
-
});
409
-
}
410
-
411
-
let ingestor_endpoint = &self.ingestor_endpoint;
406
+
pubfnget_url(&self,mode:Mode) -> Url{
407
+
let(endpoint, env_var) = match mode {
408
+
Mode::Ingest => {
409
+
ifself.ingestor_endpoint.is_empty(){
410
+
returnformat!(
411
+
"{}://{}",
412
+
self.get_scheme(),
413
+
self.address
414
+
)
415
+
.parse::<Url>()// if the value was improperly set, this will panic before hand
416
+
.unwrap_or_else(|err| {
417
+
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)
418
+
});
419
+
}
420
+
(&self.ingestor_endpoint,"P_INGESTOR_ENDPOINT")
421
+
}
422
+
Mode::Index => {
423
+
ifself.indexer_endpoint.is_empty(){
424
+
returnformat!(
425
+
"{}://{}",
426
+
self.get_scheme(),
427
+
self.address
428
+
)
429
+
.parse::<Url>()// if the value was improperly set, this will panic before hand
430
+
.unwrap_or_else(|err| {
431
+
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)
432
+
});
433
+
}
434
+
(&self.indexer_endpoint,"P_INDEXER_ENDPOINT")
435
+
}
436
+
_ => panic!("Invalid mode"),
437
+
};
412
438
413
-
ifingestor_endpoint.starts_with("http"){
414
-
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);
439
+
ifendpoint.starts_with("http"){
440
+
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);
415
441
}
416
442
417
-
let addr_from_env = ingestor_endpoint.split(':').collect::<Vec<&str>>();
443
+
let addr_from_env = endpoint.split(':').collect::<Vec<&str>>();
418
444
419
445
if addr_from_env.len() != 2{
420
-
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);
446
+
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