diff options
Diffstat (limited to 'src/utils')
-rw-r--r-- | src/utils/deploy.rs | 2 | ||||
-rw-r--r-- | src/utils/mod.rs | 34 | ||||
-rw-r--r-- | src/utils/push.rs | 2 |
3 files changed, 18 insertions, 20 deletions
diff --git a/src/utils/deploy.rs b/src/utils/deploy.rs index adcde64..a82fa6c 100644 --- a/src/utils/deploy.rs +++ b/src/utils/deploy.rs @@ -82,7 +82,7 @@ pub enum DeployProfileError { pub async fn deploy_profile( deploy_data: &super::DeployData<'_>, - deploy_defs: &super::DeployDefs<'_>, + deploy_defs: &super::DeployDefs, ) -> Result<(), DeployProfileError> { info!( "Activating profile `{}` for node `{}`", diff --git a/src/utils/mod.rs b/src/utils/mod.rs index 76d638d..2c114f5 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -2,7 +2,6 @@ // // SPDX-License-Identifier: MPL-2.0 -use std::borrow::Cow; use std::path::PathBuf; use merge::Merge; @@ -96,7 +95,7 @@ fn test_parse_flake() { ); } -#[derive(Debug)] +#[derive(Debug, Clone)] pub struct DeployData<'a> { pub node_name: &'a str, pub node: &'a data::Node, @@ -109,10 +108,10 @@ pub struct DeployData<'a> { } #[derive(Debug)] -pub struct DeployDefs<'a> { - pub ssh_user: Cow<'a, str>, - pub profile_user: Cow<'a, str>, - pub profile_path: Cow<'a, str>, +pub struct DeployDefs { + pub ssh_user: String, + pub profile_user: String, + pub profile_path: String, pub current_exe: PathBuf, pub sudo: Option<String>, } @@ -128,16 +127,16 @@ pub enum DeployDataDefsError { } impl<'a> DeployData<'a> { - pub fn defs(&'a self) -> Result<DeployDefs<'a>, DeployDataDefsError> { - let ssh_user: Cow<str> = match self.merged_settings.ssh_user { - Some(ref u) => u.into(), - None => whoami::username().into(), + pub fn defs(&'a self) -> Result<DeployDefs, DeployDataDefsError> { + let ssh_user = match self.merged_settings.ssh_user { + Some(ref u) => u.clone(), + None => whoami::username(), }; - let profile_user: Cow<str> = match self.merged_settings.user { - Some(ref x) => x.into(), + let profile_user = match self.merged_settings.user { + Some(ref x) => x.clone(), None => match self.merged_settings.ssh_user { - Some(ref x) => x.into(), + Some(ref x) => x.clone(), None => { return Err(DeployDataDefsError::NoProfileUser( self.profile_name.to_owned(), @@ -147,16 +146,15 @@ impl<'a> DeployData<'a> { }, }; - let profile_path: Cow<str> = match self.profile.profile_settings.profile_path { + let profile_path = match self.profile.profile_settings.profile_path { None => match &profile_user[..] { - "root" => format!("/nix/var/nix/profiles/{}", self.profile_name).into(), + "root" => format!("/nix/var/nix/profiles/{}", self.profile_name), _ => format!( "/nix/var/nix/profiles/per-user/{}/{}", profile_user, self.profile_name - ) - .into(), + ), }, - Some(ref x) => x.into(), + Some(ref x) => x.clone(), }; let sudo: Option<String> = match self.merged_settings.user { diff --git a/src/utils/push.rs b/src/utils/push.rs index 2ea259a..18b97b5 100644 --- a/src/utils/push.rs +++ b/src/utils/push.rs @@ -30,7 +30,7 @@ pub async fn push_profile( check_sigs: bool, repo: &str, deploy_data: &super::DeployData<'_>, - deploy_defs: &super::DeployDefs<'_>, + deploy_defs: &super::DeployDefs, keep_result: bool, result_path: Option<&str>, extra_build_args: &[String], |