diff options
-rw-r--r-- | examples/simple/flake.lock | 10 | ||||
-rw-r--r-- | examples/system/flake.lock | 10 | ||||
-rw-r--r-- | interface/deploy.json | 44 | ||||
-rw-r--r-- | src/main.rs | 28 | ||||
-rw-r--r-- | src/utils/data.rs | 15 |
5 files changed, 61 insertions, 46 deletions
diff --git a/examples/simple/flake.lock b/examples/simple/flake.lock index 1e2fab0..8f4ca88 100644 --- a/examples/simple/flake.lock +++ b/examples/simple/flake.lock @@ -7,10 +7,12 @@ "utils": "utils" }, "locked": { - "lastModified": 1601952388, - "narHash": "sha256-g5t4JNUl4xmKfKmzo5yzligVNTBHOTgw+vkuebP4B/Q=", - "type": "git", - "url": "file:///home/notgne2/Dev/Serokell/deploy-rs" + "lastModified": 1601952901, + "narHash": "sha256-6U0JIlh6GLqkxdyUiVRbph9k1lVCtWLno2uM/Fd/ZzI=", + "owner": "serokell", + "repo": "deploy-rs", + "rev": "1de1ad5ff893bfcabdf2bfa20d8c93a8cdbb0156", + "type": "github" }, "original": { "owner": "serokell", diff --git a/examples/system/flake.lock b/examples/system/flake.lock index d3e489a..8f4ca88 100644 --- a/examples/system/flake.lock +++ b/examples/system/flake.lock @@ -7,10 +7,12 @@ "utils": "utils" }, "locked": { - "lastModified": 1601668691, - "narHash": "sha256-HvzPMsgSOQfCRoPtkwLRv09CkNjOsLHjcZtyHF+8Zbs=", - "type": "git", - "url": "file:///home/notgne2/Dev/Serokell/deploy-rs" + "lastModified": 1601952901, + "narHash": "sha256-6U0JIlh6GLqkxdyUiVRbph9k1lVCtWLno2uM/Fd/ZzI=", + "owner": "serokell", + "repo": "deploy-rs", + "rev": "1de1ad5ff893bfcabdf2bfa20d8c93a8cdbb0156", + "type": "github" }, "original": { "owner": "serokell", diff --git a/interface/deploy.json b/interface/deploy.json index aaa6534..310e926 100644 --- a/interface/deploy.json +++ b/interface/deploy.json @@ -31,6 +31,29 @@ "properties": { "hostname": { "type": "string" + }, + "profilesOrder": { + "type": "array", + "items": { + "type": "string" + }, + "uniqueItems": true + }, + "profiles": { + "type": "object", + "patternProperties": { + "[A-z][A-z0-9_-]*": { + "allOf": [ + { + "$ref": "#/definitions/generic_settings" + }, + { + "$ref": "#/definitions/profile_settings" + } + ] + } + }, + "additionalProperties": false } }, "required": [ @@ -70,27 +93,6 @@ }, { "$ref": "#/definitions/node_settings" - }, - { - "type": "object", - "properties": { - "profiles": { - "type": "object", - "patternProperties": { - "[A-z][A-z0-9_-]*": { - "allOf": [ - { - "$ref": "#/definitions/generic_settings" - }, - { - "$ref": "#/definitions/profile_settings" - } - ] - } - }, - "additionalProperties": false - } - } } ] } diff --git a/src/main.rs b/src/main.rs index 219c3e5..fb3fb66 100644 --- a/src/main.rs +++ b/src/main.rs @@ -65,17 +65,22 @@ async fn push_all_profiles( ) -> Result<(), Box<dyn std::error::Error>> { info!("Pushing all profiles for `{}`", node_name); - let mut profiles_list: Vec<&str> = node.profiles_order.iter().map(|x| x.as_ref()).collect(); + let mut profiles_list: Vec<&str> = node + .node_settings + .profiles_order + .iter() + .map(|x| x.as_ref()) + .collect(); // Add any profiles which weren't in the provided order list - for profile_name in node.profiles.keys() { + for profile_name in node.node_settings.profiles.keys() { if !profiles_list.contains(&profile_name.as_str()) { profiles_list.push(&profile_name); } } for profile_name in profiles_list { - let profile = match node.profiles.get(profile_name) { + let profile = match node.node_settings.profiles.get(profile_name) { Some(x) => x, None => good_panic!("No profile was found named `{}`", profile_name), }; @@ -117,17 +122,22 @@ async fn deploy_all_profiles( ) -> Result<(), Box<dyn std::error::Error>> { info!("Deploying all profiles for `{}`", node_name); - let mut profiles_list: Vec<&str> = node.profiles_order.iter().map(|x| x.as_ref()).collect(); + let mut profiles_list: Vec<&str> = node + .node_settings + .profiles_order + .iter() + .map(|x| x.as_ref()) + .collect(); // Add any profiles which weren't in the provided order list - for profile_name in node.profiles.keys() { + for profile_name in node.node_settings.profiles.keys() { if !profiles_list.contains(&profile_name.as_str()) { profiles_list.push(&profile_name); } } for profile_name in profiles_list { - let profile = match node.profiles.get(profile_name) { + let profile = match node.node_settings.profiles.get(profile_name) { Some(x) => x, None => good_panic!("No profile was found named `{}`", profile_name), }; @@ -203,8 +213,8 @@ async fn get_deployment_data( } let build_output = build_command - .stdout(Stdio::null()) - .stderr(Stdio::null()) + // .stdout(Stdio::null()) + // .stderr(Stdio::null()) .output() .await?; @@ -233,7 +243,7 @@ async fn run_deploy( Some(x) => x, None => good_panic!("No node was found named `{}`", node_name), }; - let profile = match node.profiles.get(profile_name) { + let profile = match node.node_settings.profiles.get(profile_name) { Some(x) => x, None => good_panic!("No profile was found named `{}`", profile_name), }; diff --git a/src/utils/data.rs b/src/utils/data.rs index de6adfc..371c82d 100644 --- a/src/utils/data.rs +++ b/src/utils/data.rs @@ -29,6 +29,13 @@ pub struct GenericSettings { #[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)] @@ -51,14 +58,6 @@ pub struct Node { pub generic_settings: GenericSettings, #[serde(flatten)] pub node_settings: NodeSettings, - - 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)] |