aboutsummaryrefslogtreecommitdiff
path: root/src/utils/push.rs
diff options
context:
space:
mode:
authornotgne22020-10-01 18:21:40 -0700
committernotgne22020-10-01 18:21:40 -0700
commite14acaf2bdc14bbdc30f3d558b62f64fe33ff5f9 (patch)
treed3e146a017de239d756dfd4a0f3afa8ee94e2832 /src/utils/push.rs
parentea5aab76849ba3ce9ff2b7eba2a391d4ea33fa3a (diff)
Rework system for deploy properties, add CLI override flags
Diffstat (limited to 'src/utils/push.rs')
-rw-r--r--src/utils/push.rs46
1 files changed, 23 insertions, 23 deletions
diff --git a/src/utils/push.rs b/src/utils/push.rs
index 38a576f..9a6748e 100644
--- a/src/utils/push.rs
+++ b/src/utils/push.rs
@@ -2,30 +2,24 @@
//
// SPDX-License-Identifier: MPL-2.0
-use super::data;
-
use std::process::Stdio;
use tokio::process::Command;
pub async fn push_profile(
- profile: &data::Profile,
- profile_name: &str,
- node: &data::Node,
- node_name: &str,
supports_flakes: bool,
check_sigs: bool,
repo: &str,
- merged_settings: &data::GenericSettings,
deploy_data: &super::DeployData<'_>,
+ deploy_defs: &super::DeployDefs<'_>,
) -> Result<(), Box<dyn std::error::Error>> {
info!(
"Pushing profile `{}` for node `{}`",
- profile_name, node_name
+ deploy_data.profile_name, deploy_data.node_name
);
debug!(
"Building profile `{} for node `{}`",
- profile_name, node_name
+ deploy_data.profile_name, deploy_data.node_name
);
if supports_flakes {
@@ -34,7 +28,7 @@ pub async fn push_profile(
.arg("--no-link")
.arg(format!(
"{}#deploy.nodes.{}.profiles.{}.path",
- repo, node_name, profile_name
+ repo, deploy_data.node_name, deploy_data.profile_name
))
.stdout(Stdio::null())
.stderr(Stdio::null())
@@ -46,7 +40,7 @@ pub async fn push_profile(
.arg("-A")
.arg(format!(
"deploy.nodes.{}.profiles.{}.path",
- node_name, profile_name
+ deploy_data.node_name, deploy_data.profile_name
))
.stdout(Stdio::null())
.stderr(Stdio::null())
@@ -57,7 +51,7 @@ pub async fn push_profile(
if let Ok(local_key) = std::env::var("LOCAL_KEY") {
info!(
"Signing key present! Signing profile `{}` for node `{}`",
- profile_name, node_name
+ deploy_data.profile_name, deploy_data.node_name
);
Command::new("nix")
@@ -65,9 +59,9 @@ pub async fn push_profile(
.arg("-r")
.arg("-k")
.arg(local_key)
- .arg(&profile.profile_settings.path)
+ .arg(&deploy_data.profile.profile_settings.path)
.arg(&super::deploy_path_to_activate_path_str(
- &deploy_data.current_exe,
+ &deploy_defs.current_exe,
)?)
.stdout(Stdio::null())
.stderr(Stdio::null())
@@ -75,12 +69,15 @@ pub async fn push_profile(
.await?;
}
- debug!("Copying profile `{} for node `{}`", profile_name, node_name);
+ debug!(
+ "Copying profile `{} for node `{}`",
+ deploy_data.profile_name, deploy_data.node_name
+ );
let mut copy_command_ = Command::new("nix");
let mut copy_command = copy_command_.arg("copy");
- if merged_settings.fast_connection {
+ if deploy_data.merged_settings.fast_connection {
copy_command = copy_command.arg("--substitute-on-destination");
}
@@ -88,7 +85,8 @@ pub async fn push_profile(
copy_command = copy_command.arg("--no-check-sigs");
}
- let ssh_opts_str = merged_settings
+ let ssh_opts_str = deploy_data
+ .merged_settings
.ssh_opts
// This should provide some extra safety, but it also breaks for some reason, oh well
// .iter()
@@ -96,15 +94,17 @@ pub async fn push_profile(
// .collect::<Vec<String>>()
.join(" ");
+ let hostname = match deploy_data.cmd_overrides.hostname {
+ Some(ref x) => x,
+ None => &deploy_data.node.node_settings.hostname,
+ };
+
copy_command
.arg("--to")
- .arg(format!(
- "ssh://{}@{}",
- deploy_data.ssh_user, node.node_settings.hostname
- ))
- .arg(&profile.profile_settings.path)
+ .arg(format!("ssh://{}@{}", deploy_defs.ssh_user, hostname))
+ .arg(&deploy_data.profile.profile_settings.path)
.arg(&super::deploy_path_to_activate_path_str(
- &deploy_data.current_exe,
+ &deploy_defs.current_exe,
)?)
.env("NIX_SSHOPTS", ssh_opts_str)
.spawn()?