diff options
author | Andreas Fuchs | 2020-11-25 19:20:17 -0500 |
---|---|---|
committer | notgne2 | 2020-12-02 10:24:23 -0700 |
commit | c1e0f5a9c9f6402703aece1581fd00ab20f71ded (patch) | |
tree | f15eb7a18ab6c4d36efa3ecb5bb4aad949d29db9 /src | |
parent | 4af6b8114e1edb8d8280e10ab295c1cacef94136 (diff) |
Use DeployData's store path to build the activate-rs path
This gets rid of yet more code, so - win!
Diffstat (limited to 'src')
-rw-r--r-- | src/utils/deploy.rs | 13 | ||||
-rw-r--r-- | src/utils/mod.rs | 20 | ||||
-rw-r--r-- | src/utils/push.rs | 1 |
3 files changed, 4 insertions, 30 deletions
diff --git a/src/utils/deploy.rs b/src/utils/deploy.rs index b37909e..3e2eb4c 100644 --- a/src/utils/deploy.rs +++ b/src/utils/deploy.rs @@ -8,7 +8,6 @@ use tokio::process::Command; use thiserror::Error; fn build_activate_command( - activate_path_str: String, sudo: &Option<String>, profile_path: &str, closure: &str, @@ -18,8 +17,8 @@ fn build_activate_command( magic_rollback: bool, ) -> String { let mut self_activate_command = format!( - "{} '{}' '{}' --temp-path {} --confirm-timeout {}", - activate_path_str, profile_path, closure, temp_path, confirm_timeout + "{}/activate-rs '{}' '{}' --temp-path {} --confirm-timeout {}", + closure, profile_path, closure, temp_path, confirm_timeout ); if magic_rollback { @@ -42,7 +41,7 @@ fn test_activation_command_builder() { let activate_path_str = "/blah/bin/activate".to_string(); let sudo = Some("sudo -u test".to_string()); let profile_path = "/blah/profiles/test"; - let closure = "/blah/etc"; + let closure = "/nix/store/blah/etc"; let auto_rollback = true; let temp_path = &"/tmp".into(); let confirm_timeout = 30; @@ -50,7 +49,6 @@ fn test_activation_command_builder() { assert_eq!( build_activate_command( - activate_path_str, &sudo, profile_path, closure, @@ -59,7 +57,7 @@ fn test_activation_command_builder() { confirm_timeout, magic_rollback ), - "sudo -u test /blah/bin/activate '/blah/profiles/test' '/blah/etc' --temp-path /tmp --confirm-timeout 30 --magic-rollback --auto-rollback" + "sudo -u test /nix/store/blah/etc/activate-rs '/blah/profiles/test' '/nix/store/blah/etc' --temp-path /tmp --confirm-timeout 30 --magic-rollback --auto-rollback" .to_string(), ); } @@ -89,8 +87,6 @@ pub async fn deploy_profile( deploy_data.profile_name, deploy_data.node_name ); - let activate_path_str = super::deploy_path_to_activate_path_str(deploy_defs)?; - let temp_path: Cow<str> = match &deploy_data.merged_settings.temp_path { Some(x) => x.into(), None => "/tmp".into(), @@ -103,7 +99,6 @@ pub async fn deploy_profile( let auto_rollback = deploy_data.merged_settings.auto_rollback.unwrap_or(true); let self_activate_command = build_activate_command( - activate_path_str, &deploy_defs.sudo, &deploy_defs.profile_path, &deploy_data.profile.profile_settings.path, diff --git a/src/utils/mod.rs b/src/utils/mod.rs index 6052813..02ea85b 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -312,23 +312,3 @@ pub enum DeployPathToActivatePathError { #[error("Deploy path was not valid utf8")] InvalidUtf8, } - -pub fn deploy_path_to_activate_path_str( - deploy_defs: &DeployDefs, -) -> Result<String, DeployPathToActivatePathError> { - Ok(format!("{}/activate-rs", deploy_defs.profile_path)) -} - -#[test] -fn test_activate_path_generation() { - let defs = DeployDefs { - ssh_user: "foo".to_string(), - profile_user: "bar".to_string(), - profile_path: "/nix/store/profile-closure".to_string(), - sudo: None, - }; - match deploy_path_to_activate_path_str(&defs) { - Err(_) => panic!(""), - Ok(x) => assert_eq!(x, "/nix/store/profile-closure/activate-rs".to_string()), - } -} diff --git a/src/utils/push.rs b/src/utils/push.rs index 237e99a..76e87c9 100644 --- a/src/utils/push.rs +++ b/src/utils/push.rs @@ -99,7 +99,6 @@ pub async fn push_profile( .arg("-k") .arg(local_key) .arg(&deploy_data.profile.profile_settings.path) - .arg(&super::deploy_path_to_activate_path_str(&deploy_defs)?) .status() .await .map_err(PushProfileError::SignError)?; |