Skip to content

Commit b65da8c

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 52ebb62 commit b65da8c

4 files changed

Lines changed: 31 additions & 5 deletions

File tree

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

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@ fn allow_empty_path() -> impl clap::builder::TypedValueParser<Value = PathBuf> {
6868
#[derive(clap::Args, Debug, Default)]
6969
struct ConfigPreflightArgs {
7070
/// Explicit configuration path. Overrides `OPENSHELL_GATEWAY_CONFIG` and XDG discovery.
71-
#[arg(long, conflicts_with = "gateway_args")]
71+
///
72+
/// `--config` is an alias that matches the daemon flag.
73+
#[arg(long, visible_alias = "config", conflicts_with = "gateway_args")]
7274
path: Option<PathBuf>,
7375

7476
/// Explicit drop-in directory. Defaults to `gateway.d` next to the base file.
@@ -2344,6 +2346,30 @@ mod tests {
23442346
});
23452347
}
23462348

2349+
#[test]
2350+
fn preflight_accepts_config_as_an_alias_for_path() {
2351+
for flag in ["--path", "--config"] {
2352+
let cli = Cli::try_parse_from([
2353+
"openshell-gateway",
2354+
"config",
2355+
"preflight",
2356+
flag,
2357+
"/etc/gateway.toml",
2358+
])
2359+
.unwrap();
2360+
let Some(super::Commands::Config(super::ConfigArgs {
2361+
command: super::ConfigCommand::Preflight(args),
2362+
})) = cli.command
2363+
else {
2364+
panic!("expected the preflight subcommand");
2365+
};
2366+
assert_eq!(
2367+
args.path,
2368+
Some(std::path::PathBuf::from("/etc/gateway.toml"))
2369+
);
2370+
}
2371+
}
2372+
23472373
#[test]
23482374
fn command_parses_bind_address() {
23492375
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

@@ -175,7 +175,7 @@ configured in the TOML file passed with **--config**.
175175

176176
Validate a gateway configuration before starting the daemon:
177177

178-
openshell-gateway config preflight [[--path PATH] [--config-dir DIR] | -- GATEWAY_ARGS...]
178+
openshell-gateway config preflight [[--path PATH (alias --config)] [--config-dir DIR] | -- GATEWAY_ARGS...]
179179

180180
With no path, preflight validates a nonempty OPENSHELL_GATEWAY_CONFIG. If that
181181
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
@@ -2289,7 +2289,7 @@ changing it:
22892289
openshell-gateway config preflight --path ~/.config/openshell/gateway.toml
22902290
```
22912291

2292-
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, and it still loads a `gateway.d` directory beside the default config path when one holds drop-in configs. 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 failure found after the configuration loads, such as an invalid driver setting, reports only the base file, or the drop-in directory when there is no base file, and no detail, even when a drop-in config set the key. A failed preflight always preserves the file; it never migrates, replaces, or rewrites configuration.
2292+
`--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, and it still loads a `gateway.d` directory beside the default config path when one holds drop-in configs. 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 failure found after the configuration loads, such as an invalid driver setting, reports only the base file, or the drop-in directory when there is no base file, and no detail, even when a drop-in config set the key. A failed preflight always preserves the file; it never migrates, replaces, or rewrites configuration.
22932293

22942294
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.
22952295

‎skills/debug-openshell-cluster/SKILL.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1756,7 +1756,7 @@ For a Debian, Ubuntu, or snap gateway that stops before certificate generation o
17561756
daemon startup, validate the selected configuration without starting the service:
17571757

17581758
```shell
1759-
openshell-gateway config preflight [[--path PATH] [--config-dir DIR] | -- GATEWAY_ARGS...]
1759+
openshell-gateway config preflight [[--path PATH (alias --config)] [--config-dir DIR] | -- GATEWAY_ARGS...]
17601760
```
17611761

17621762
Without a path, preflight validates a nonempty `OPENSHELL_GATEWAY_CONFIG` or an

0 commit comments

Comments
 (0)