diff --git a/src/config.rs b/src/config.rs index 5d727316..8d0b3394 100644 --- a/src/config.rs +++ b/src/config.rs @@ -225,7 +225,10 @@ impl Config { Some(Cluster { nodes: filtered_nodes, - defaults: ClusterDefaults::default(), + defaults: ClusterDefaults { + ssh_key: Some("/home/config/ssh/id_cluster".to_string()), + ..ClusterDefaults::default() + }, interactive: None, }) } diff --git a/tests/backendai_env_test.rs b/tests/backendai_env_test.rs index 1be355ac..24be7ff1 100644 --- a/tests/backendai_env_test.rs +++ b/tests/backendai_env_test.rs @@ -51,6 +51,13 @@ async fn test_backendai_env_auto_detection() { // Get the bai_auto cluster let cluster = config.clusters.get("bai_auto").unwrap(); + // Verify SSH key is set to Backend.AI cluster key + assert_eq!( + cluster.defaults.ssh_key, + Some("/home/config/ssh/id_cluster".to_string()), + "Backend.AI cluster should use /home/config/ssh/id_cluster as SSH key" + ); + // Verify nodes were parsed correctly assert_eq!(cluster.nodes.len(), 3); @@ -66,6 +73,13 @@ async fn test_backendai_env_auto_detection() { assert_eq!(nodes[1].host, "node2.ai"); assert_eq!(nodes[2].host, "node3.ai"); + // Verify get_ssh_key returns the correct key for Backend.AI cluster + assert_eq!( + config.get_ssh_key(Some("bai_auto")), + Some("/home/config/ssh/id_cluster".to_string()), + "get_ssh_key should return Backend.AI cluster key path" + ); + // Restore original env vars unsafe { if let Some(val) = orig_hosts {