Skip to content

Commit 7312432

Browse files
authored
feat: use Backend.AI cluster SSH key for auto-detected environments (#16)
1 parent 149bca2 commit 7312432

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

src/config.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,10 @@ impl Config {
225225

226226
Some(Cluster {
227227
nodes: filtered_nodes,
228-
defaults: ClusterDefaults::default(),
228+
defaults: ClusterDefaults {
229+
ssh_key: Some("/home/config/ssh/id_cluster".to_string()),
230+
..ClusterDefaults::default()
231+
},
229232
interactive: None,
230233
})
231234
}

tests/backendai_env_test.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,13 @@ async fn test_backendai_env_auto_detection() {
5151
// Get the bai_auto cluster
5252
let cluster = config.clusters.get("bai_auto").unwrap();
5353

54+
// Verify SSH key is set to Backend.AI cluster key
55+
assert_eq!(
56+
cluster.defaults.ssh_key,
57+
Some("/home/config/ssh/id_cluster".to_string()),
58+
"Backend.AI cluster should use /home/config/ssh/id_cluster as SSH key"
59+
);
60+
5461
// Verify nodes were parsed correctly
5562
assert_eq!(cluster.nodes.len(), 3);
5663

@@ -66,6 +73,13 @@ async fn test_backendai_env_auto_detection() {
6673
assert_eq!(nodes[1].host, "node2.ai");
6774
assert_eq!(nodes[2].host, "node3.ai");
6875

76+
// Verify get_ssh_key returns the correct key for Backend.AI cluster
77+
assert_eq!(
78+
config.get_ssh_key(Some("bai_auto")),
79+
Some("/home/config/ssh/id_cluster".to_string()),
80+
"get_ssh_key should return Backend.AI cluster key path"
81+
);
82+
6983
// Restore original env vars
7084
unsafe {
7185
if let Some(val) = orig_hosts {

0 commit comments

Comments
 (0)