diff options
Diffstat (limited to '')
-rw-r--r-- | src/utils/deploy.rs | 26 | ||||
-rw-r--r-- | src/utils/mod.rs | 24 | ||||
-rw-r--r-- | src/utils/push.rs | 10 |
3 files changed, 31 insertions, 29 deletions
diff --git a/src/utils/deploy.rs b/src/utils/deploy.rs index 9c258fd..1abae64 100644 --- a/src/utils/deploy.rs +++ b/src/utils/deploy.rs @@ -6,30 +6,6 @@ use super::data; use tokio::process::Command; -fn deploy_path_to_activate_path_str( - deploy_path: &std::path::Path, -) -> Result<String, Box<dyn std::error::Error>> { - Ok(format!( - "{}/activate", - deploy_path - .parent() - .ok_or("Deploy path too short")? - .to_str() - .ok_or("Deploy path is not valid utf8")? - .to_owned() - )) -} - -#[test] -fn test_activate_path_generation() { - match deploy_path_to_activate_path_str(&std::path::PathBuf::from( - "/blah/blah/deploy-rs/bin/deploy", - )) { - Err(_) => panic!(""), - Ok(x) => assert_eq!(x, "/blah/blah/deploy-rs/bin/activate".to_string()), - } -} - fn build_activate_command( activate_path_str: String, sudo: &Option<String>, @@ -105,7 +81,7 @@ pub async fn deploy_profile( profile_name, node_name ); - let activate_path_str = deploy_path_to_activate_path_str(&deploy_data.current_exe)?; + let activate_path_str = super::deploy_path_to_activate_path_str(&deploy_data.current_exe)?; let self_activate_command = build_activate_command( activate_path_str, diff --git a/src/utils/mod.rs b/src/utils/mod.rs index 5802627..30201c3 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -136,3 +136,27 @@ pub async fn make_deploy_data<'a>( current_exe, }) } + +pub fn deploy_path_to_activate_path_str( + deploy_path: &std::path::Path, +) -> Result<String, Box<dyn std::error::Error>> { + Ok(format!( + "{}/activate", + deploy_path + .parent() + .ok_or("Deploy path too short")? + .to_str() + .ok_or("Deploy path is not valid utf8")? + .to_owned() + )) +} + +#[test] +fn test_activate_path_generation() { + match deploy_path_to_activate_path_str(&std::path::PathBuf::from( + "/blah/blah/deploy-rs/bin/deploy", + )) { + Err(_) => panic!(""), + Ok(x) => assert_eq!(x, "/blah/blah/deploy-rs/bin/activate".to_string()), + } +} diff --git a/src/utils/push.rs b/src/utils/push.rs index c87c32b..38a576f 100644 --- a/src/utils/push.rs +++ b/src/utils/push.rs @@ -66,7 +66,9 @@ pub async fn push_profile( .arg("-k") .arg(local_key) .arg(&profile.profile_settings.path) - .arg(&deploy_data.current_exe) + .arg(&super::deploy_path_to_activate_path_str( + &deploy_data.current_exe, + )?) .stdout(Stdio::null()) .stderr(Stdio::null()) .spawn()? @@ -101,10 +103,10 @@ pub async fn push_profile( deploy_data.ssh_user, node.node_settings.hostname )) .arg(&profile.profile_settings.path) - .arg(&deploy_data.current_exe) + .arg(&super::deploy_path_to_activate_path_str( + &deploy_data.current_exe, + )?) .env("NIX_SSHOPTS", ssh_opts_str) - .stdout(Stdio::null()) - .stderr(Stdio::null()) .spawn()? .await?; |