diff options
author | notgne2 | 2020-09-28 12:25:30 -0700 |
---|---|---|
committer | notgne2 | 2020-09-28 12:25:30 -0700 |
commit | 00f75951211bacc5bab4317e56376f03c74dabb7 (patch) | |
tree | 667e002f8634c8219c4757524dec292333bd8fb5 /src | |
parent | 1b9cb58802cd295bd91b822812f195c02367e350 (diff) |
Add (untested) profiles order support
Diffstat (limited to 'src')
-rw-r--r-- | src/main.rs | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/main.rs b/src/main.rs index 0599b11..9d55efc 100644 --- a/src/main.rs +++ b/src/main.rs @@ -122,6 +122,12 @@ pub struct Node { 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)] @@ -348,7 +354,21 @@ async fn deploy_all_profiles( .await?; } - for (profile_name, profile) in &node.profiles { + let mut profiles_list: Vec<&str> = node.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 { + 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) { + Some(x) => x, + None => good_panic!("No profile was found named `{}`", profile_name), + }; + // This will have already been deployed if prime && profile_name == "system" { continue; |