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.
()
| 121 | /// Returns the first driver where the environment check passes. |
| 122 | /// Returns `None` if no compatible driver is found. |
| 123 | pub 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. |
| 143 | fn is_binary_available(name: &str) -> bool { |