Skip to content

Commit 3a7a654

Browse files
refactor(server): use a single static no-driver-configured message
Drop `no_driver_configured_message` and `compiled_in_builtin_names` in favor of an inline static error. The dynamic list of supported drivers belonged in a discoverable channel (a future `openshell-gateway info` subcommand, tracked separately) rather than in an error message the operator can only reach by triggering a failure. Adjust `configured_compute_driver_empty_points_at_extensions_when_no_builtins` to assert only the socket_path escape hatch, which the single static message still surfaces for the extension-only build shape. Signed-off-by: Dimitar Mirchev <[email protected]>
1 parent 85c4144 commit 3a7a654

1 file changed

Lines changed: 6 additions & 48 deletions

File tree

  • crates/openshell-server/src

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

Lines changed: 6 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -877,7 +877,12 @@ fn configured_compute_driver(
877877
"vm compute driver is opt-in only; set --drivers vm or OPENSHELL_DRIVERS=vm",
878878
)),
879879
Some(driver) => Ok(ConfiguredComputeDriver::Builtin(driver)),
880-
None => Err(Error::config(no_driver_configured_message())),
880+
None => Err(Error::config(
881+
"no compute driver configured and auto-detection found no suitable driver; \
882+
set --drivers or OPENSHELL_DRIVERS to a supported driver, \
883+
or to an extension driver name with a matching \
884+
[openshell.drivers.<name>].socket_path",
885+
)),
881886
},
882887
[driver] => resolve_configured_compute_driver(driver, driver_startup),
883888
drivers => Err(Error::config(format!(
@@ -887,49 +892,6 @@ fn configured_compute_driver(
887892
}
888893
}
889894

890-
/// Error message when no compute driver is configured and auto-detection
891-
/// finds nothing usable.
892-
fn no_driver_configured_message() -> String {
893-
let builtins = compiled_in_builtin_names();
894-
if builtins.is_empty() {
895-
// No built-ins were compiled in, so auto-detection had nothing to try.
896-
// Point operators at the only path that can succeed in this binary.
897-
"no compute driver configured and auto-detection found no suitable driver; \
898-
this gateway was built without any in-tree drivers, so `compute_drivers` \
899-
must name an extension driver with a matching \
900-
[openshell.drivers.<name>].socket_path"
901-
.to_string()
902-
} else {
903-
format!(
904-
"no compute driver configured and auto-detection found no suitable driver; \
905-
set --drivers or OPENSHELL_DRIVERS to one of: {} \
906-
(or to an extension driver name with a matching \
907-
[openshell.drivers.<name>].socket_path)",
908-
builtins.join(", "),
909-
)
910-
}
911-
}
912-
913-
/// Names of the built-in compute drivers linked into this binary, in the
914-
/// stable order expected by user-facing messages. Empty when the gateway was
915-
/// built as extension-only (no `driver-*` features).
916-
fn compiled_in_builtin_names() -> Vec<&'static str> {
917-
let mut names = Vec::new();
918-
if cfg!(feature = "driver-kubernetes") {
919-
names.push("kubernetes");
920-
}
921-
if cfg!(feature = "driver-podman") {
922-
names.push("podman");
923-
}
924-
if cfg!(feature = "driver-docker") {
925-
names.push("docker");
926-
}
927-
if cfg!(feature = "driver-vm") {
928-
names.push("vm");
929-
}
930-
names
931-
}
932-
933895
fn resolve_configured_compute_driver(
934896
driver_name: &str,
935897
driver_startup: compute::driver_config::DriverStartupContext<'_>,
@@ -1378,10 +1340,6 @@ mod tests {
13781340
let err =
13791341
configured_compute_driver(&config, test_driver_startup(&config, None)).unwrap_err();
13801342
let msg = err.to_string();
1381-
assert!(
1382-
msg.contains("without any in-tree drivers"),
1383-
"expected extension-only guidance, got: {msg}"
1384-
);
13851343
assert!(
13861344
msg.contains("socket_path"),
13871345
"expected extension socket_path guidance, got: {msg}"

0 commit comments

Comments
 (0)