aboutsummaryrefslogtreecommitdiff
path: root/src/data.rs
diff options
context:
space:
mode:
authornotgne22021-01-24 18:20:58 -0700
committerGitHub2021-01-24 18:20:58 -0700
commita33127ad4144282696b061af61c188e75ee49452 (patch)
treef8dad55ca7372c1b21d9567fe955b4c6abadf42c /src/data.rs
parent726d758768d7b8071dcffa14560a14f588460406 (diff)
parent9850b951f5a95841afd7633d3ca9fac7b67d0a3f (diff)
Merge pull request #45 from serokell/notgne2/cleanup
Code cleanup
Diffstat (limited to 'src/data.rs')
-rw-r--r--src/data.rs73
1 files changed, 73 insertions, 0 deletions
diff --git a/src/data.rs b/src/data.rs
new file mode 100644
index 0000000..f557e41
--- /dev/null
+++ b/src/data.rs
@@ -0,0 +1,73 @@
+// SPDX-FileCopyrightText: 2020 Serokell <https://serokell.io/>
+//
+// SPDX-License-Identifier: MPL-2.0
+
+use merge::Merge;
+
+use std::collections::HashMap;
+
+#[derive(Deserialize, Debug, Clone, Merge)]
+pub struct GenericSettings {
+ #[serde(rename(deserialize = "sshUser"))]
+ pub ssh_user: Option<String>,
+ pub user: Option<String>,
+ #[serde(
+ skip_serializing_if = "Vec::is_empty",
+ default,
+ rename(deserialize = "sshOpts")
+ )]
+ #[merge(strategy = merge::vec::append)]
+ pub ssh_opts: Vec<String>,
+ #[serde(rename(deserialize = "fastConnection"))]
+ pub fast_connection: Option<bool>,
+ #[serde(rename(deserialize = "autoRollback"))]
+ pub auto_rollback: Option<bool>,
+ #[serde(rename(deserialize = "confirmTimeout"))]
+ pub confirm_timeout: Option<u16>,
+ #[serde(rename(deserialize = "tempPath"))]
+ pub temp_path: Option<String>,
+ #[serde(rename(deserialize = "magicRollback"))]
+ pub magic_rollback: Option<bool>,
+}
+
+#[derive(Deserialize, Debug, Clone)]
+pub struct NodeSettings {
+ pub hostname: String,
+ pub profiles: HashMap<String, Profile>,
+ #[serde(
+ skip_serializing_if = "Vec::is_empty",
+ default,
+ rename(deserialize = "profilesOrder")
+ )]
+ pub profiles_order: Vec<String>,
+}
+
+#[derive(Deserialize, Debug, Clone)]
+pub struct ProfileSettings {
+ pub path: String,
+ #[serde(rename(deserialize = "profilePath"))]
+ pub profile_path: Option<String>,
+}
+
+#[derive(Deserialize, Debug, Clone)]
+pub struct Profile {
+ #[serde(flatten)]
+ pub profile_settings: ProfileSettings,
+ #[serde(flatten)]
+ pub generic_settings: GenericSettings,
+}
+
+#[derive(Deserialize, Debug, Clone)]
+pub struct Node {
+ #[serde(flatten)]
+ pub generic_settings: GenericSettings,
+ #[serde(flatten)]
+ pub node_settings: NodeSettings,
+}
+
+#[derive(Deserialize, Debug, Clone)]
+pub struct Data {
+ #[serde(flatten)]
+ pub generic_settings: GenericSettings,
+ pub nodes: HashMap<String, Node>,
+}