diff options
author | notgne2 | 2020-09-28 15:45:53 -0700 |
---|---|---|
committer | notgne2 | 2020-09-28 15:45:53 -0700 |
commit | 239d0f8999b47e9e76589ee1fa2d9f3459c47335 (patch) | |
tree | d9fa64da2385dcb3cf254a92e00fa92d2431c155 /src/utils | |
parent | a22063343e54da9f589c7235f2f64b57fe5c257b (diff) |
use separate binary for activation, more cleanup
Diffstat (limited to 'src/utils')
-rw-r--r-- | src/utils/data.rs | 10 | ||||
-rw-r--r-- | src/utils/deploy.rs | 17 | ||||
-rw-r--r-- | src/utils/push.rs | 2 |
3 files changed, 22 insertions, 7 deletions
diff --git a/src/utils/data.rs b/src/utils/data.rs index b28b6cd..0753508 100644 --- a/src/utils/data.rs +++ b/src/utils/data.rs @@ -14,10 +14,12 @@ pub struct GenericSettings { )] #[merge(strategy = merge::vec::append)] pub ssh_opts: Vec<String>, - #[serde(rename(deserialize = "fastConnection"))] - pub fast_connection: Option<bool>, - #[serde(rename(deserialize = "autoRollback"))] - pub auto_rollback: Option<String>, + #[serde(rename(deserialize = "fastConnection"), default)] + #[merge(strategy = merge::bool::overwrite_false)] + pub fast_connection: bool, + #[serde(rename(deserialize = "autoRollback"), default)] + #[merge(strategy = merge::bool::overwrite_false)] + pub auto_rollback: bool, } #[derive(Deserialize, Debug, Clone)] diff --git a/src/utils/deploy.rs b/src/utils/deploy.rs index 900743c..42bd0b4 100644 --- a/src/utils/deploy.rs +++ b/src/utils/deploy.rs @@ -9,6 +9,7 @@ pub async fn deploy_profile( node_name: &str, merged_settings: &data::GenericSettings, deploy_data: &super::DeployData<'_>, + auto_rollback: bool, ) -> Result<(), Box<dyn std::error::Error>> { info!( "Activating profile `{}` for node `{}`", @@ -16,8 +17,16 @@ pub async fn deploy_profile( ); let mut self_activate_command = format!( - "{} activate '{}' '{}'", - deploy_data.current_exe.as_path().to_str().unwrap(), + "{} '{}' '{}'", + deploy_data + .current_exe + .as_path() + .parent() + .unwrap() + .to_str() + .unwrap() + .to_owned() + + "/activate", deploy_data.profile_path, profile.profile_settings.path, ); @@ -40,6 +49,10 @@ pub async fn deploy_profile( ); } + if auto_rollback { + self_activate_command = format!("{} --auto-rollback", self_activate_command); + } + let mut c = Command::new("ssh"); let mut ssh_command = c.arg(format!( "ssh://{}@{}", diff --git a/src/utils/push.rs b/src/utils/push.rs index 54ae013..0e1b9ba 100644 --- a/src/utils/push.rs +++ b/src/utils/push.rs @@ -74,7 +74,7 @@ pub async fn push_profile( let mut copy_command_ = Command::new("nix"); let mut copy_command = copy_command_.arg("copy"); - if let Some(true) = merged_settings.fast_connection { + if merged_settings.fast_connection { copy_command = copy_command.arg("--substitute-on-destination"); } |