Skip to content

Commit 12855a4

Browse files
committed
feat(gateway): accept --config as an alias for config preflight --path
Match the daemon flag so the same name selects the base config file in both places. Keep --path for compatibility. Signed-off-by: Evan Lezar <elezar@nvidia.com>
1 parent 4fab887 commit 12855a4

3 files changed

Lines changed: 30 additions & 4 deletions

File tree

‎crates/openshell-server/src/cli.rs‎

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@ enum ConfigCommand {
6262
#[derive(clap::Args, Debug, Default)]
6363
struct ConfigPreflightArgs {
6464
/// Explicit configuration path. Overrides `OPENSHELL_GATEWAY_CONFIG` and XDG discovery.
65-
#[arg(long, conflicts_with = "gateway_args")]
65+
///
66+
/// `--config` is an alias that matches the daemon flag.
67+
#[arg(long, visible_alias = "config", conflicts_with = "gateway_args")]
6668
path: Option<PathBuf>,
6769

6870
/// Explicit drop-in directory. Defaults to `gateway.d` next to the base file.
@@ -2118,6 +2120,30 @@ mod tests {
21182120
});
21192121
}
21202122

2123+
#[test]
2124+
fn preflight_accepts_config_as_an_alias_for_path() {
2125+
for flag in ["--path", "--config"] {
2126+
let cli = Cli::try_parse_from([
2127+
"openshell-gateway",
2128+
"config",
2129+
"preflight",
2130+
flag,
2131+
"/etc/gateway.toml",
2132+
])
2133+
.unwrap();
2134+
let Some(super::Commands::Config(super::ConfigArgs {
2135+
command: super::ConfigCommand::Preflight(args),
2136+
})) = cli.command
2137+
else {
2138+
panic!("expected the preflight subcommand");
2139+
};
2140+
assert_eq!(
2141+
args.path,
2142+
Some(std::path::PathBuf::from("/etc/gateway.toml"))
2143+
);
2144+
}
2145+
}
2146+
21212147
#[test]
21222148
fn command_parses_bind_address() {
21232149
Environment::new().remove("OPENSHELL_BIND_ADDRESS").run(|| {

‎deploy/man/openshell-gateway.8.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ openshell-gateway - OpenShell gateway server daemon
1414

1515
**openshell-gateway** \[*OPTIONS*\]
1616

17-
**openshell-gateway** **config preflight** [**--path** *PATH* | **--config-dir** *DIR* | **--** *GATEWAY_ARGS*...]
17+
**openshell-gateway** **config preflight** [**--path** *PATH* (alias **--config**) | **--config-dir** *DIR* | **--** *GATEWAY_ARGS*...]
1818

1919
# DESCRIPTION
2020

@@ -172,7 +172,7 @@ configured in the TOML file passed with **--config**.
172172

173173
Validate a gateway configuration before starting the daemon:
174174

175-
openshell-gateway config preflight [--path PATH | -- GATEWAY_ARGS...]
175+
openshell-gateway config preflight [--path PATH (alias --config) | -- GATEWAY_ARGS...]
176176

177177
With no path, preflight validates a nonempty OPENSHELL_GATEWAY_CONFIG. If that
178178
variable is unset, it optionally validates an auto-discovered XDG config. The

‎docs/how-it-works/gateways/configuration.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1906,7 +1906,7 @@ changing it:
19061906
openshell-gateway config preflight --path ~/.config/openshell/gateway.toml
19071907
```
19081908

1909-
Without `--path`, the command validates a nonempty `OPENSHELL_GATEWAY_CONFIG`. Otherwise, it validates an existing XDG gateway config when one is discovered. When neither source selects a config, preflight validates the effective daemon arguments. An explicit missing path, a legacy schema-v1 file, invalid TOML, a symlink, or any nonregular file fails. Preflight also loads the drop-in configs, prints the files it merged, and fails on the same errors as startup; pass `--config-dir` to select a directory. It merges the selected file with the current `OPENSHELL_*` environment and applies the daemon's read-only startup checks. These checks include selector and socket normalization, registered-driver selection and configuration, rate-limit pairs, TLS and mTLS relationships, interceptor registrations, and supervisor middleware registrations. When a selected file omits `compute_driver`, preflight validates each configured table for an auto-detectable driver without running the runtime detection probes, which can connect local sockets or launch discovery commands. It validates configured driver TLS requirements, including the gateway CA, without requiring package-generated certificate files to exist before certificate generation. It does not construct a compute driver or connect to a transport. A failed preflight always preserves the file; it never migrates, replaces, or rewrites configuration.
1909+
`--config` is an alias for `--path`. Without either, the command validates a nonempty `OPENSHELL_GATEWAY_CONFIG`. Otherwise, it validates an existing XDG gateway config when one is discovered. When neither source selects a config, preflight validates the effective daemon arguments. An explicit missing path, a legacy schema-v1 file, invalid TOML, a symlink, or any nonregular file fails. Preflight also loads the drop-in configs, prints the files it merged, and fails on the same errors as startup; pass `--config-dir` to select a directory. It merges the selected file with the current `OPENSHELL_*` environment and applies the daemon's read-only startup checks. These checks include selector and socket normalization, registered-driver selection and configuration, rate-limit pairs, TLS and mTLS relationships, interceptor registrations, and supervisor middleware registrations. When a selected file omits `compute_driver`, preflight validates each configured table for an auto-detectable driver without running the runtime detection probes, which can connect local sockets or launch discovery commands. It validates configured driver TLS requirements, including the gateway CA, without requiring package-generated certificate files to exist before certificate generation. It does not construct a compute driver or connect to a transport. A failed preflight always preserves the file; it never migrates, replaces, or rewrites configuration.
19101910

19111911
Config preflight validates configuration without loading launch-signing keys, so a successful result does not confirm that the key files exist or form a usable pair. Gateway startup validates configured or discovered signing bundles. Sandbox creation checks the selected driver's launch-signing requirement before image preparation.
19121912

0 commit comments

Comments
 (0)