xianyun_cluster/driver/auto.rs
1//! Port of `internal/cluster/auto/driver.go`: an "auto" driver that resolves
2//! to colima or k3d depending on the host OS, so `cluster.driver: auto` in
3//! `caproni.yaml` picks a sensible default per platform.
4
5use super::Driver as DriverTrait;
6use xianyun_core::config::types::ClusterConfig;
7
8pub const DRIVER_NAME: &str = "auto";
9
10/// Port of `auto.newAutoManager`: resolves `goos` to a concrete driver
11/// (colima on darwin, k3d elsewhere) and returns it directly — the returned
12/// value's `Name()` reports the resolved driver, not "auto".
13#[must_use]
14pub fn new_auto_manager(
15 goos: &str,
16 cfg: ClusterConfig,
17 profile_name: String,
18) -> Box<dyn DriverTrait> {
19 if goos == "linux" {
20 return Box::new(super::k3d::Driver::new(cfg, profile_name));
21 }
22
23 Box::new(super::colima::Driver::new(cfg, profile_name))
24}