MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / detect_driver

Function detect_driver

crates/openshell-core/src/config.rs:123–140  ·  view source on GitHub ↗

Auto-detect the appropriate compute driver based on the runtime environment. Priority order: Kubernetes → Podman → Docker. VM is never auto-detected (requires explicit `--drivers vm`). Returns the first driver where the environment check passes. Returns `None` if no compatible driver is found.

()

Source from the content-addressed store, hash-verified

121/// Returns the first driver where the environment check passes.
122/// Returns `None` if no compatible driver is found.
123pub fn detect_driver() -> Option<ComputeDriverKind> {
124 // Kubernetes: check for KUBERNETES_SERVICE_HOST env var (set inside pods)
125 if std::env::var_os("KUBERNETES_SERVICE_HOST").is_some() {
126 return Some(ComputeDriverKind::Kubernetes);
127 }
128
129 // Podman: check for a reachable local API socket.
130 if is_podman_available() {
131 return Some(ComputeDriverKind::Podman);
132 }
133
134 // Docker: check if the CLI is available or a local Docker socket exists.
135 if is_docker_available() {
136 return Some(ComputeDriverKind::Docker);
137 }
138
139 None
140}
141
142/// Check if a binary is available on the system PATH.
143fn is_binary_available(name: &str) -> bool {

Calls 2

is_podman_availableFunction · 0.85
is_docker_availableFunction · 0.85