/ src / data.rs
data.rs
 1  // SPDX-FileCopyrightText: 2020 Serokell <https://serokell.io/>
 2  //
 3  // SPDX-License-Identifier: MPL-2.0
 4  
 5  use merge::Merge;
 6  use serde::Deserialize;
 7  use std::collections::HashMap;
 8  use std::path::PathBuf;
 9  
10  #[derive(Deserialize, Debug, Clone, Merge)]
11  pub struct GenericSettings {
12      #[serde(rename(deserialize = "sshUser"))]
13      pub ssh_user: Option<String>,
14      pub user: Option<String>,
15      #[serde(
16          skip_serializing_if = "Vec::is_empty",
17          default,
18          rename(deserialize = "sshOpts")
19      )]
20      #[merge(strategy = merge::vec::append)]
21      pub ssh_opts: Vec<String>,
22      #[serde(rename(deserialize = "fastConnection"))]
23      pub fast_connection: Option<bool>,
24      #[serde(rename(deserialize = "autoRollback"))]
25      pub auto_rollback: Option<bool>,
26      #[serde(rename(deserialize = "confirmTimeout"))]
27      pub confirm_timeout: Option<u16>,
28      #[serde(rename(deserialize = "activationTimeout"))]
29      pub activation_timeout: Option<u16>,
30      #[serde(rename(deserialize = "tempPath"))]
31      pub temp_path: Option<PathBuf>,
32      #[serde(rename(deserialize = "magicRollback"))]
33      pub magic_rollback: Option<bool>,
34      #[serde(rename(deserialize = "sudo"))]
35      pub sudo: Option<String>,
36      #[serde(default,rename(deserialize = "remoteBuild"))]
37      pub remote_build: Option<bool>,
38      #[serde(rename(deserialize = "interactiveSudo"))]
39      pub interactive_sudo: Option<bool>,
40  }
41  
42  #[derive(Deserialize, Debug, Clone)]
43  pub struct NodeSettings {
44      pub hostname: String,
45      pub profiles: HashMap<String, Profile>,
46      #[serde(
47          skip_serializing_if = "Vec::is_empty",
48          default,
49          rename(deserialize = "profilesOrder")
50      )]
51      pub profiles_order: Vec<String>,
52  }
53  
54  #[derive(Deserialize, Debug, Clone)]
55  pub struct ProfileSettings {
56      pub path: String,
57      #[serde(rename(deserialize = "profilePath"))]
58      pub profile_path: Option<String>,
59  }
60  
61  #[derive(Deserialize, Debug, Clone)]
62  pub struct Profile {
63      #[serde(flatten)]
64      pub profile_settings: ProfileSettings,
65      #[serde(flatten)]
66      pub generic_settings: GenericSettings,
67  }
68  
69  #[derive(Deserialize, Debug, Clone)]
70  pub struct Node {
71      #[serde(flatten)]
72      pub generic_settings: GenericSettings,
73      #[serde(flatten)]
74      pub node_settings: NodeSettings,
75  }
76  
77  #[derive(Deserialize, Debug, Clone)]
78  pub struct Data {
79      #[serde(flatten)]
80      pub generic_settings: GenericSettings,
81      pub nodes: HashMap<String, Node>,
82  }