aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornotgne22020-09-28 13:55:46 -0700
committernotgne22020-09-28 13:55:46 -0700
commitff347d4204369d40b6b04eedf8e2421bcd7018ab (patch)
tree26911b38f56c4955bc1549f3d9797e0603ed0253
parenta71eaa3cec59e8084f890bf89efbffc5f765fd9e (diff)
Crudely perform pushes before deploys, with little data re-use (untested)
-rw-r--r--src/main.rs135
1 files changed, 69 insertions, 66 deletions
diff --git a/src/main.rs b/src/main.rs
index a3c526f..59b79a5 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -351,81 +351,63 @@ async fn deploy_profile(
Ok(())
}
-async fn deploy_profile_todo(
- top_settings: &GenericSettings,
- profile: &Profile,
- profile_name: &str,
- node: &Node,
- node_name: &str,
- supports_flakes: bool,
- check_sigs: bool,
- repo: &str,
-) -> Result<(), Box<dyn std::error::Error>> {
- let mut merged_settings = top_settings.clone();
- merged_settings.merge(node.generic_settings.clone());
- merged_settings.merge(profile.generic_settings.clone());
-
- let deploy_data = make_deploy_data(profile_name, node_name, &merged_settings).await?;
-
- push_profile(
- profile,
- profile_name,
- node,
- node_name,
- supports_flakes,
- check_sigs,
- repo,
- &merged_settings,
- &deploy_data,
- )
- .await?;
-
- deploy_profile(
- profile,
- profile_name,
- node,
- node_name,
- &merged_settings,
- &deploy_data,
- )
- .await?;
-
- Ok(())
-}
-
#[inline]
-async fn deploy_all_profiles(
+async fn push_all_profiles(
node: &Node,
node_name: &str,
supports_flakes: bool,
repo: &str,
top_settings: &GenericSettings,
- prime: bool,
check_sigs: bool,
) -> Result<(), Box<dyn std::error::Error>> {
info!("Deploying all profiles for `{}`", node_name);
- if prime {
- info!("Bootstrapping {}", node_name);
+ 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);
+ }
+ }
- let profile = match node.profiles.get("system") {
+ for profile_name in profiles_list {
+ let profile = match node.profiles.get(profile_name) {
Some(x) => x,
- None => good_panic!("No system profile was found, needed for priming"),
+ None => good_panic!("No profile was found named `{}`", profile_name),
};
- deploy_profile_todo(
- top_settings,
+ let mut merged_settings = top_settings.clone();
+ merged_settings.merge(node.generic_settings.clone());
+ merged_settings.merge(profile.generic_settings.clone());
+
+ let deploy_data = make_deploy_data(profile_name, node_name, &merged_settings).await?;
+
+ push_profile(
profile,
- "system",
+ profile_name,
node,
node_name,
supports_flakes,
check_sigs,
repo,
+ &merged_settings,
+ &deploy_data,
)
.await?;
}
+ Ok(())
+}
+
+#[inline]
+async fn deploy_all_profiles(
+ node: &Node,
+ node_name: &str,
+ top_settings: &GenericSettings,
+) -> 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();
// Add any profiles which weren't in the provided order list
@@ -441,20 +423,19 @@ async fn deploy_all_profiles(
None => good_panic!("No profile was found named `{}`", profile_name),
};
- // This will have already been deployed
- if prime && profile_name == "system" {
- continue;
- }
+ let mut merged_settings = top_settings.clone();
+ merged_settings.merge(node.generic_settings.clone());
+ merged_settings.merge(profile.generic_settings.clone());
+
+ let deploy_data = make_deploy_data(profile_name, node_name, &merged_settings).await?;
- deploy_profile_todo(
- top_settings,
+ deploy_profile(
profile,
profile_name,
node,
node_name,
- supports_flakes,
- check_sigs,
- repo,
+ &merged_settings,
+ &deploy_data,
)
.await?;
}
@@ -547,8 +528,14 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
None => good_panic!("No profile was found named `{}`", profile_name),
};
- deploy_profile_todo(
- &data.generic_settings,
+ let mut merged_settings = data.generic_settings.clone();
+ merged_settings.merge(node.generic_settings.clone());
+ merged_settings.merge(profile.generic_settings.clone());
+
+ let deploy_data =
+ make_deploy_data(profile_name, node_name, &merged_settings).await?;
+
+ push_profile(
profile,
profile_name,
node,
@@ -556,6 +543,18 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
supports_flakes,
deploy_opts.checksigs,
repo,
+ &merged_settings,
+ &deploy_data,
+ )
+ .await?;
+
+ deploy_profile(
+ profile,
+ profile_name,
+ node,
+ node_name,
+ &merged_settings,
+ &deploy_data,
)
.await?;
}
@@ -565,32 +564,36 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
None => good_panic!("No node was found named `{}`", node_name),
};
- deploy_all_profiles(
+ push_all_profiles(
node,
node_name,
supports_flakes,
repo,
&data.generic_settings,
- deploy_opts.prime,
deploy_opts.checksigs,
)
.await?;
+
+ deploy_all_profiles(node, node_name, &data.generic_settings).await?;
}
(None, None) => {
info!("Deploying all profiles on all nodes");
for (node_name, node) in &data.nodes {
- deploy_all_profiles(
+ push_all_profiles(
node,
node_name,
supports_flakes,
repo,
&data.generic_settings,
- deploy_opts.prime,
deploy_opts.checksigs,
)
.await?;
}
+
+ for (node_name, node) in &data.nodes {
+ deploy_all_profiles(node, node_name, &data.generic_settings).await?;
+ }
}
(None, Some(_)) => good_panic!(
"Profile provided without a node, this is not (currently) supported"