Apply gateway-wide values from `[openshell.gateway]` onto `RunArgs` for every argument that is still sourced from clap's built-in default. The function intentionally does not touch `database_url` — that secret is env-only and the loader already rejected it when it appears in the file.
(args: &mut RunArgs, file: &GatewayFileSection, matches: &ArgMatches)
| 568 | /// The function intentionally does not touch `database_url` — that secret is |
| 569 | /// env-only and the loader already rejected it when it appears in the file. |
| 570 | fn merge_file_into_args(args: &mut RunArgs, file: &GatewayFileSection, matches: &ArgMatches) { |
| 571 | if let Some(addr) = file.bind_address { |
| 572 | if arg_defaulted(matches, "bind_address") { |
| 573 | args.bind_address = addr.ip(); |
| 574 | } |
| 575 | if arg_defaulted(matches, "port") { |
| 576 | args.port = addr.port(); |
| 577 | } |
| 578 | } |
| 579 | // Note: file's full health_bind_address / metrics_bind_address are |
| 580 | // consumed in `run_from_args`'s listener-resolution block so the IP |
| 581 | // half of the SocketAddr is preserved. Copying only the port here |
| 582 | // would silently relocate a loopback-intended listener onto the |
| 583 | // public bind address. |
| 584 | if let Some(level) = &file.log_level |
| 585 | && arg_defaulted(matches, "log_level") |
| 586 | { |
| 587 | args.log_level.clone_from(level); |
| 588 | } |
| 589 | if let Some(drivers) = &file.compute_drivers |
| 590 | && arg_defaulted(matches, "drivers") |
| 591 | { |
| 592 | args.drivers.clone_from(drivers); |
| 593 | } |
| 594 | if let Some(sans) = &file.server_sans |
| 595 | && args.server_sans.is_empty() |
| 596 | && arg_defaulted(matches, "server_sans") |
| 597 | { |
| 598 | args.server_sans.clone_from(sans); |
| 599 | } |
| 600 | if let Some(enabled) = file.enable_loopback_service_http |
| 601 | && arg_defaulted(matches, "enable_loopback_service_http") |
| 602 | { |
| 603 | args.enable_loopback_service_http = enabled; |
| 604 | } |
| 605 | if let Some(mtls_auth) = &file.mtls_auth |
| 606 | && arg_defaulted(matches, "enable_mtls_auth") |
| 607 | { |
| 608 | args.enable_mtls_auth = mtls_auth.enabled; |
| 609 | } |
| 610 | if let Some(disabled) = file.disable_tls |
| 611 | && arg_defaulted(matches, "disable_tls") |
| 612 | { |
| 613 | args.disable_tls = disabled; |
| 614 | } |
| 615 | // TLS gateway listener fields |
| 616 | if let Some(tls) = &file.tls { |
| 617 | if args.tls_cert.is_none() && arg_defaulted(matches, "tls_cert") { |
| 618 | args.tls_cert = Some(tls.cert_path.clone()); |
| 619 | } |
| 620 | if args.tls_key.is_none() && arg_defaulted(matches, "tls_key") { |
| 621 | args.tls_key = Some(tls.key_path.clone()); |
| 622 | } |
| 623 | if args.tls_client_ca.is_none() && arg_defaulted(matches, "tls_client_ca") { |
| 624 | args.tls_client_ca.clone_from(&tls.client_ca_path); |
| 625 | } |
| 626 | } |
| 627 | // OIDC fields |