Skip to main content

smbcloud_utils/
config.rs

1use {
2    serde::{Deserialize, Serialize},
3    smbcloud_model::project::Project,
4};
5
6/// smbCloud config from the .smb/config.toml file.
7#[derive(Deserialize, Serialize)]
8pub struct Config {
9    pub name: String,
10    pub description: Option<String>,
11    pub project: Project,
12    pub projects: Option<Vec<Project>>,
13}
14
15impl Config {
16    pub fn ssh_key_path(&self, user_id: i32) -> String {
17        // Use the dirs crate to get the home directory
18        let home = dirs::home_dir().expect("Could not determine home directory");
19        let key_path = home.join(".ssh").join(format!("id_{}@smbcloud", user_id));
20        let key_path_str = key_path.to_string_lossy().to_string();
21        println!("Use key path: {}", key_path_str);
22        key_path_str
23    }
24}