aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/bin/activate.rs88
-rw-r--r--src/cli.rs47
-rw-r--r--src/deploy.rs66
-rw-r--r--src/lib.rs6
-rw-r--r--src/push.rs40
5 files changed, 117 insertions, 130 deletions
diff --git a/src/bin/activate.rs b/src/bin/activate.rs
index 9cf8819..d0cfbe1 100644
--- a/src/bin/activate.rs
+++ b/src/bin/activate.rs
@@ -95,23 +95,23 @@ struct RevokeOpts {
#[derive(Error, Debug)]
pub enum DeactivateError {
#[error("Failed to execute the rollback command: {0}")]
- RollbackError(std::io::Error),
+ Rollback(std::io::Error),
#[error("The rollback resulted in a bad exit code: {0:?}")]
- RollbackExitError(Option<i32>),
+ RollbackExit(Option<i32>),
#[error("Failed to run command for listing generations: {0}")]
- ListGenError(std::io::Error),
+ ListGen(std::io::Error),
#[error("Command for listing generations resulted in a bad exit code: {0:?}")]
- ListGenExitError(Option<i32>),
+ ListGenExit(Option<i32>),
#[error("Error converting generation list output to utf8: {0}")]
- DecodeListGenUtf8Error(#[from] std::string::FromUtf8Error),
+ DecodeListGenUtf8(std::string::FromUtf8Error),
#[error("Failed to run command for deleting generation: {0}")]
- DeleteGenError(std::io::Error),
+ DeleteGen(std::io::Error),
#[error("Command for deleting generations resulted in a bad exit code: {0:?}")]
- DeleteGenExitError(Option<i32>),
+ DeleteGenExit(Option<i32>),
#[error("Failed to run command for re-activating the last generation: {0}")]
- ReactivateError(std::io::Error),
+ Reactivate(std::io::Error),
#[error("Command for re-activating the last generation resulted in a bad exit code: {0:?}")]
- ReactivateExitError(Option<i32>),
+ ReactivateExit(Option<i32>),
}
pub async fn deactivate(profile_path: &str) -> Result<(), DeactivateError> {
@@ -123,11 +123,11 @@ pub async fn deactivate(profile_path: &str) -> Result<(), DeactivateError> {
.arg("--rollback")
.status()
.await
- .map_err(DeactivateError::RollbackError)?;
+ .map_err(DeactivateError::Rollback)?;
match nix_env_rollback_exit_status.code() {
Some(0) => (),
- a => return Err(DeactivateError::RollbackExitError(a)),
+ a => return Err(DeactivateError::RollbackExit(a)),
};
debug!("Listing generations");
@@ -138,14 +138,15 @@ pub async fn deactivate(profile_path: &str) -> Result<(), DeactivateError> {
.arg("--list-generations")
.output()
.await
- .map_err(DeactivateError::ListGenError)?;
+ .map_err(DeactivateError::ListGen)?;
match nix_env_list_generations_out.status.code() {
Some(0) => (),
- a => return Err(DeactivateError::ListGenExitError(a)),
+ a => return Err(DeactivateError::ListGenExit(a)),
};
- let generations_list = String::from_utf8(nix_env_list_generations_out.stdout)?;
+ let generations_list = String::from_utf8(nix_env_list_generations_out.stdout)
+ .map_err(DeactivateError::DecodeListGenUtf8)?;
let last_generation_line = generations_list
.lines()
@@ -167,11 +168,11 @@ pub async fn deactivate(profile_path: &str) -> Result<(), DeactivateError> {
.arg(last_generation_id)
.status()
.await
- .map_err(DeactivateError::DeleteGenError)?;
+ .map_err(DeactivateError::DeleteGen)?;
match nix_env_delete_generation_exit_status.code() {
Some(0) => (),
- a => return Err(DeactivateError::DeleteGenExitError(a)),
+ a => return Err(DeactivateError::DeleteGenExit(a)),
};
info!("Attempting to re-activate the last generation");
@@ -181,11 +182,11 @@ pub async fn deactivate(profile_path: &str) -> Result<(), DeactivateError> {
.current_dir(&profile_path)
.status()
.await
- .map_err(DeactivateError::ReactivateError)?;
+ .map_err(DeactivateError::Reactivate)?;
match re_activate_exit_status.code() {
Some(0) => (),
- a => return Err(DeactivateError::ReactivateExitError(a)),
+ a => return Err(DeactivateError::ReactivateExit(a)),
};
Ok(())
@@ -194,15 +195,11 @@ pub async fn deactivate(profile_path: &str) -> Result<(), DeactivateError> {
#[derive(Error, Debug)]
pub enum ActivationConfirmationError {
#[error("Failed to create activation confirmation directory: {0}")]
- CreateConfirmDirError(std::io::Error),
+ CreateConfirmDir(std::io::Error),
#[error("Failed to create activation confirmation file: {0}")]
- CreateConfirmFileError(std::io::Error),
- #[error("Failed to create file system watcher instance: {0}")]
- CreateWatcherError(notify::Error),
- #[error("Error forking process: {0}")]
- ForkError(i32),
+ CreateConfirmFile(std::io::Error),
#[error("Could not watch for activation sentinel: {0}")]
- WatcherError(#[from] notify::Error),
+ Watcher(#[from] notify::Error),
}
#[derive(Error, Debug)]
@@ -212,7 +209,7 @@ pub enum DangerZoneError {
#[error("inotify stream ended without activation confirmation")]
NoConfirmation,
#[error("inotify encountered an error: {0}")]
- WatchError(notify::Error),
+ Watch(notify::Error),
}
async fn danger_zone(
@@ -223,7 +220,7 @@ async fn danger_zone(
match timeout(Duration::from_secs(confirm_timeout as u64), events.recv()).await {
Ok(Some(Ok(()))) => Ok(()),
- Ok(Some(Err(e))) => Err(DangerZoneError::WatchError(e)),
+ Ok(Some(Err(e))) => Err(DangerZoneError::Watch(e)),
Ok(None) => Err(DangerZoneError::NoConfirmation),
Err(_) => Err(DangerZoneError::TimesUp),
}
@@ -242,14 +239,14 @@ pub async fn activation_confirmation(
if let Some(parent) = Path::new(&lock_path).parent() {
fs::create_dir_all(parent)
.await
- .map_err(ActivationConfirmationError::CreateConfirmDirError)?;
+ .map_err(ActivationConfirmationError::CreateConfirmDir)?;
}
debug!("Creating canary file");
fs::File::create(&lock_path)
.await
- .map_err(ActivationConfirmationError::CreateConfirmFileError)?;
+ .map_err(ActivationConfirmationError::CreateConfirmFile)?;
debug!("Creating notify watcher");
@@ -342,20 +339,20 @@ pub async fn wait(temp_path: String, closure: String) -> Result<(), WaitError> {
#[derive(Error, Debug)]
pub enum ActivateError {
#[error("Failed to execute the command for setting profile: {0}")]
- SetProfileError(std::io::Error),
+ SetProfile(std::io::Error),
#[error("The command for setting profile resulted in a bad exit code: {0:?}")]
- SetProfileExitError(Option<i32>),
+ SetProfileExit(Option<i32>),
#[error("Failed to execute the activation script: {0}")]
- RunActivateError(std::io::Error),
+ RunActivate(std::io::Error),
#[error("The activation script resulted in a bad exit code: {0:?}")]
- RunActivateExitError(Option<i32>),
+ RunActivateExit(Option<i32>),
#[error("There was an error de-activating after an error was encountered: {0}")]
- DeactivateError(#[from] DeactivateError),
+ Deactivate(#[from] DeactivateError),
#[error("Failed to get activation confirmation: {0}")]
- ActivationConfirmationError(#[from] ActivationConfirmationError),
+ ActivationConfirmation(#[from] ActivationConfirmationError),
}
pub async fn activate(
@@ -376,14 +373,14 @@ pub async fn activate(
.arg(&closure)
.status()
.await
- .map_err(ActivateError::SetProfileError)?;
+ .map_err(ActivateError::SetProfile)?;
match nix_env_set_exit_status.code() {
Some(0) => (),
a => {
if auto_rollback && !dry_activate {
deactivate(&profile_path).await?;
}
- return Err(ActivateError::SetProfileExitError(a));
+ return Err(ActivateError::SetProfileExit(a));
}
};
}
@@ -402,7 +399,7 @@ pub async fn activate(
.current_dir(activation_location)
.status()
.await
- .map_err(ActivateError::RunActivateError)
+ .map_err(ActivateError::RunActivate)
{
Ok(x) => x,
Err(e) => {
@@ -420,7 +417,7 @@ pub async fn activate(
if auto_rollback {
deactivate(&profile_path).await?;
}
- return Err(ActivateError::RunActivateExitError(a));
+ return Err(ActivateError::RunActivateExit(a));
}
};
@@ -437,7 +434,7 @@ pub async fn activate(
Ok(()) => {}
Err(err) => {
deactivate(&profile_path).await?;
- return Err(ActivateError::ActivationConfirmationError(err));
+ return Err(ActivateError::ActivationConfirmation(err));
}
};
}
@@ -446,12 +443,7 @@ pub async fn activate(
Ok(())
}
-#[derive(Error, Debug)]
-pub enum RevokeError {
- #[error("There was an error de-activating after an error was encountered: {0}")]
- DeactivateError(#[from] DeactivateError),
-}
-async fn revoke(profile_path: String) -> Result<(), RevokeError> {
+async fn revoke(profile_path: String) -> Result<(), DeactivateError> {
deactivate(profile_path.as_str()).await?;
Ok(())
}
@@ -462,7 +454,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut signals = Signals::new(&[SIGHUP])?;
std::thread::spawn(move || {
for _ in signals.forever() {
- println!("Received NOHUP - ignoring...");
+ println!("Received SIGHUP - ignoring...");
}
});
@@ -471,7 +463,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
deploy::init_logger(
opts.debug_logs,
opts.log_dir.as_deref(),
- match opts.subcmd {
+ &match opts.subcmd {
SubCommand::Activate(_) => deploy::LoggerType::Activate,
SubCommand::Wait(_) => deploy::LoggerType::Wait,
SubCommand::Revoke(_) => deploy::LoggerType::Revoke,
diff --git a/src/cli.rs b/src/cli.rs
index 33eb5bb..61890e4 100644
--- a/src/cli.rs
+++ b/src/cli.rs
@@ -6,7 +6,7 @@
use std::collections::HashMap;
use std::io::{stdin, stdout, Write};
-use clap::{Clap, ArgMatches, FromArgMatches};
+use clap::{ArgMatches, Clap, FromArgMatches};
use crate as deploy;
@@ -127,16 +127,13 @@ async fn check_deployment(
false => Command::new("nix-build"),
};
- match supports_flakes {
- true => {
- check_command.arg("flake").arg("check").arg(repo);
- }
- false => {
- check_command.arg("-E")
+ if supports_flakes {
+ check_command.arg("flake").arg("check").arg(repo);
+ } else {
+ check_command.arg("-E")
.arg("--no-out-link")
.arg(format!("let r = import {}/.; x = (if builtins.isFunction r then (r {{}}) else r); in if x ? checks then x.checks.${{builtins.currentSystem}} else {{}}", repo));
- }
- };
+ }
for extra_arg in extra_build_args {
check_command.arg(extra_arg);
@@ -420,16 +417,16 @@ async fn run_deploy(
(Some(node_name), Some(profile_name)) => {
let node = match data.nodes.get(node_name) {
Some(x) => x,
- None => Err(RunDeployError::NodeNotFound(node_name.to_owned()))?,
+ None => return Err(RunDeployError::NodeNotFound(node_name.clone())),
};
let profile = match node.node_settings.profiles.get(profile_name) {
Some(x) => x,
- None => Err(RunDeployError::ProfileNotFound(profile_name.to_owned()))?,
+ None => return Err(RunDeployError::ProfileNotFound(profile_name.clone())),
};
vec![(
- &deploy_flake,
- &data,
+ deploy_flake,
+ data,
(node_name.as_str(), node),
(profile_name.as_str(), profile),
)]
@@ -437,7 +434,7 @@ async fn run_deploy(
(Some(node_name), None) => {
let node = match data.nodes.get(node_name) {
Some(x) => x,
- None => return Err(RunDeployError::NodeNotFound(node_name.to_owned())),
+ None => return Err(RunDeployError::NodeNotFound(node_name.clone())),
};
let mut profiles_list: Vec<(&str, &deploy::data::Profile)> = Vec::new();
@@ -451,14 +448,12 @@ async fn run_deploy(
let profile = match node.node_settings.profiles.get(profile_name) {
Some(x) => x,
None => {
- return Err(RunDeployError::ProfileNotFound(
- profile_name.to_owned(),
- ))
+ return Err(RunDeployError::ProfileNotFound(profile_name.clone()))
}
};
if !profiles_list.iter().any(|(n, _)| n == profile_name) {
- profiles_list.push((&profile_name, profile));
+ profiles_list.push((profile_name, profile));
}
}
@@ -483,13 +478,13 @@ async fn run_deploy(
Some(x) => x,
None => {
return Err(RunDeployError::ProfileNotFound(
- profile_name.to_owned(),
+ profile_name.clone(),
))
}
};
if !profiles_list.iter().any(|(n, _)| n == profile_name) {
- profiles_list.push((&profile_name, profile));
+ profiles_list.push((profile_name, profile));
}
}
@@ -525,7 +520,7 @@ async fn run_deploy(
node_name,
profile,
profile_name,
- &cmd_overrides,
+ cmd_overrides,
debug_logs,
log_dir.as_deref(),
);
@@ -546,8 +541,8 @@ async fn run_deploy(
supports_flakes,
check_sigs,
repo: deploy_flake.repo,
- deploy_data: &deploy_data,
- deploy_defs: &deploy_defs,
+ deploy_data,
+ deploy_defs,
keep_result,
result_path,
extra_build_args,
@@ -616,13 +611,13 @@ pub async fn run(args: Option<&ArgMatches>) -> Result<(), RunError> {
deploy::init_logger(
opts.debug_logs,
opts.log_dir.as_deref(),
- deploy::LoggerType::Deploy,
+ &deploy::LoggerType::Deploy,
)?;
let deploys = opts
.clone()
.targets
- .unwrap_or_else(|| vec![opts.clone().target.unwrap_or(".".to_string())]);
+ .unwrap_or_else(|| vec![opts.clone().target.unwrap_or_else(|| ".".to_string())]);
let deploy_flakes: Vec<DeployFlake> = deploys
.iter()
@@ -649,7 +644,7 @@ pub async fn run(args: Option<&ArgMatches>) -> Result<(), RunError> {
}
if !opts.skip_checks {
- for deploy_flake in deploy_flakes.iter() {
+ for deploy_flake in &deploy_flakes {
check_deployment(supports_flakes, deploy_flake.repo, &opts.extra_build_args).await?;
}
}
diff --git a/src/deploy.rs b/src/deploy.rs
index 60297b5..f8fc2f9 100644
--- a/src/deploy.rs
+++ b/src/deploy.rs
@@ -24,7 +24,7 @@ struct ActivateCommandData<'a> {
dry_activate: bool,
}
-fn build_activate_command(data: ActivateCommandData) -> String {
+fn build_activate_command(data: &ActivateCommandData) -> String {
let mut self_activate_command = format!("{}/activate-rs", data.closure);
if data.debug_logs {
@@ -78,7 +78,7 @@ fn test_activation_command_builder() {
let log_dir = Some("/tmp/something.txt");
assert_eq!(
- build_activate_command(ActivateCommandData {
+ build_activate_command(&ActivateCommandData {
sudo: &sudo,
profile_path,
closure,
@@ -103,7 +103,7 @@ struct WaitCommandData<'a> {
log_dir: Option<&'a str>,
}
-fn build_wait_command(data: WaitCommandData) -> String {
+fn build_wait_command(data: &WaitCommandData) -> String {
let mut self_activate_command = format!("{}/activate-rs", data.closure);
if data.debug_logs {
@@ -135,7 +135,7 @@ fn test_wait_command_builder() {
let log_dir = Some("/tmp/something.txt");
assert_eq!(
- build_wait_command(WaitCommandData {
+ build_wait_command(&WaitCommandData {
sudo: &sudo,
closure,
temp_path,
@@ -155,7 +155,7 @@ struct RevokeCommandData<'a> {
log_dir: Option<&'a str>,
}
-fn build_revoke_command(data: RevokeCommandData) -> String {
+fn build_revoke_command(data: &RevokeCommandData) -> String {
let mut self_activate_command = format!("{}/activate-rs", data.closure);
if data.debug_logs {
@@ -184,7 +184,7 @@ fn test_revoke_command_builder() {
let log_dir = Some("/tmp/something.txt");
assert_eq!(
- build_revoke_command(RevokeCommandData {
+ build_revoke_command(&RevokeCommandData {
sudo: &sudo,
closure,
profile_path,
@@ -199,11 +199,11 @@ fn test_revoke_command_builder() {
#[derive(Error, Debug)]
pub enum ConfirmProfileError {
#[error("Failed to run confirmation command over SSH (the server should roll back): {0}")]
- SSHConfirmError(std::io::Error),
+ SSHConfirm(std::io::Error),
#[error(
"Confirming activation over SSH resulted in a bad exit code (the server should roll back): {0:?}"
)]
- SSHConfirmExitError(Option<i32>),
+ SSHConfirmExit(Option<i32>),
}
pub async fn confirm_profile(
@@ -235,11 +235,11 @@ pub async fn confirm_profile(
.arg(confirm_command)
.status()
.await
- .map_err(ConfirmProfileError::SSHConfirmError)?;
+ .map_err(ConfirmProfileError::SSHConfirm)?;
match ssh_confirm_exit_status.code() {
Some(0) => (),
- a => return Err(ConfirmProfileError::SSHConfirmExitError(a)),
+ a => return Err(ConfirmProfileError::SSHConfirmExit(a)),
};
info!("Deployment confirmed.");
@@ -250,20 +250,20 @@ pub async fn confirm_profile(
#[derive(Error, Debug)]
pub enum DeployProfileError {
#[error("Failed to spawn activation command over SSH: {0}")]
- SSHSpawnActivateError(std::io::Error),
+ SSHSpawnActivate(std::io::Error),
#[error("Failed to run activation command over SSH: {0}")]
- SSHActivateError(std::io::Error),
+ SSHActivate(std::io::Error),
#[error("Activating over SSH resulted in a bad exit code: {0:?}")]
- SSHActivateExitError(Option<i32>),
+ SSHActivateExit(Option<i32>),
#[error("Failed to run wait command over SSH: {0}")]
- SSHWaitError(std::io::Error),
+ SSHWait(std::io::Error),
#[error("Waiting over SSH resulted in a bad exit code: {0:?}")]
- SSHWaitExitError(Option<i32>),
+ SSHWaitExit(Option<i32>),
#[error("Error confirming deployment: {0}")]
- ConfirmError(#[from] ConfirmProfileError),
+ Confirm(#[from] ConfirmProfileError),
}
pub async fn deploy_profile(
@@ -289,7 +289,7 @@ pub async fn deploy_profile(
let auto_rollback = deploy_data.merged_settings.auto_rollback.unwrap_or(true);
- let self_activate_command = build_activate_command(ActivateCommandData {
+ let self_activate_command = build_activate_command(&ActivateCommandData {
sudo: &deploy_defs.sudo,
profile_path: &deploy_defs.profile_path,
closure: &deploy_data.profile.profile_settings.path,
@@ -323,11 +323,11 @@ pub async fn deploy_profile(
.arg(self_activate_command)
.status()
.await
- .map_err(DeployProfileError::SSHActivateError)?;
+ .map_err(DeployProfileError::SSHActivate)?;
match ssh_activate_exit_status.code() {
Some(0) => (),
- a => return Err(DeployProfileError::SSHActivateExitError(a)),
+ a => return Err(DeployProfileError::SSHActivateExit(a)),
};
if dry_activate {
@@ -336,7 +336,7 @@ pub async fn deploy_profile(
info!("Success activating, done!");
}
} else {
- let self_wait_command = build_wait_command(WaitCommandData {
+ let self_wait_command = build_wait_command(&WaitCommandData {
sudo: &deploy_defs.sudo,
closure: &deploy_data.profile.profile_settings.path,
temp_path: &temp_path,
@@ -349,7 +349,7 @@ pub async fn deploy_profile(
let ssh_activate = ssh_activate_command
.arg(self_activate_command)
.spawn()
- .map_err(DeployProfileError::SSHSpawnActivateError)?;
+ .map_err(DeployProfileError::SSHSpawnActivate)?;
info!("Creating activation waiter");
@@ -367,10 +367,10 @@ pub async fn deploy_profile(
let o = ssh_activate.wait_with_output().await;
let maybe_err = match o {
- Err(x) => Some(DeployProfileError::SSHActivateError(x)),
+ Err(x) => Some(DeployProfileError::SSHActivate(x)),
Ok(ref x) => match x.status.code() {
Some(0) => None,
- a => Some(DeployProfileError::SSHActivateExitError(a)),
+ a => Some(DeployProfileError::SSHActivateExit(a)),
},
};
@@ -383,9 +383,9 @@ pub async fn deploy_profile(
tokio::select! {
x = ssh_wait_command.arg(self_wait_command).status() => {
debug!("Wait command ended");
- match x.map_err(DeployProfileError::SSHWaitError)?.code() {
+ match x.map_err(DeployProfileError::SSHWait)?.code() {
Some(0) => (),
- a => return Err(DeployProfileError::SSHWaitExitError(a)),
+ a => return Err(DeployProfileError::SSHWaitExit(a)),
};
},
x = recv_activate => {
@@ -407,21 +407,21 @@ pub async fn deploy_profile(
#[derive(Error, Debug)]
pub enum RevokeProfileError {
#[error("Failed to spawn revocation command over SSH: {0}")]
- SSHSpawnRevokeError(std::io::Error),
+ SSHSpawnRevoke(std::io::Error),
#[error("Error revoking deployment: {0}")]
- SSHRevokeError(std::io::Error),
+ SSHRevoke(std::io::Error),
#[error("Revoking over SSH resulted in a bad exit code: {0:?}")]
- SSHRevokeExitError(Option<i32>),
+ SSHRevokeExit(Option<i32>),
#[error("Deployment data invalid: {0}")]
- InvalidDeployDataDefsError(#[from] DeployDataDefsError),
+ InvalidDeployDataDefs(#[from] DeployDataDefsError),
}
pub async fn revoke(
deploy_data: &crate::DeployData<'_>,
deploy_defs: &crate::DeployDefs,
) -> Result<(), RevokeProfileError> {
- let self_revoke_command = build_revoke_command(RevokeCommandData {
+ let self_revoke_command = build_revoke_command(&RevokeCommandData {
sudo: &deploy_defs.sudo,
closure: &deploy_data.profile.profile_settings.path,
profile_path: &deploy_data.get_profile_path()?,
@@ -448,15 +448,15 @@ pub async fn revoke(
let ssh_revoke = ssh_activate_command
.arg(self_revoke_command)
.spawn()
- .map_err(RevokeProfileError::SSHSpawnRevokeError)?;
+ .map_err(RevokeProfileError::SSHSpawnRevoke)?;
let result = ssh_revoke.wait_with_output().await;
match result {
- Err(x) => Err(RevokeProfileError::SSHRevokeError(x)),
+ Err(x) => Err(RevokeProfileError::SSHRevoke(x)),
Ok(ref x) => match x.status.code() {
Some(0) => Ok(()),
- a => Err(RevokeProfileError::SSHRevokeExitError(a)),
+ a => Err(RevokeProfileError::SSHRevokeExit(a)),
},
}
}
diff --git a/src/lib.rs b/src/lib.rs
index 08dcccd..981ec1e 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -18,7 +18,7 @@ pub fn make_lock_path(temp_path: &str, closure: &str) -> String {
format!("{}/deploy-rs-canary-{}", temp_path, lock_hash)
}
-fn make_emoji(level: log::Level) -> &'static str {
+const fn make_emoji(level: log::Level) -> &'static str {
match level {
log::Level::Error => "❌",
log::Level::Warn => "⚠️",
@@ -102,9 +102,9 @@ pub enum LoggerType {
pub fn init_logger(
debug_logs: bool,
log_dir: Option<&str>,
- logger_type: LoggerType,
+ logger_type: &LoggerType,
) -> Result<(), FlexiLoggerError> {
- let logger_formatter = match logger_type {
+ let logger_formatter = match &logger_type {
LoggerType::Deploy => logger_formatter_deploy,
LoggerType::Activate => logger_formatter_activate,
LoggerType::Wait => logger_formatter_wait,
diff --git a/src/push.rs b/src/push.rs
index fbf6ed7..69eba0d 100644
--- a/src/push.rs
+++ b/src/push.rs
@@ -12,19 +12,19 @@ use tokio::process::Command;
#[derive(Error, Debug)]
pub enum PushProfileError {
#[error("Failed to run Nix show-derivation command: {0}")]
- ShowDerivationError(std::io::Error),
+ ShowDerivation(std::io::Error),
#[error("Nix show-derivation command resulted in a bad exit code: {0:?}")]
- ShowDerivationExitError(Option<i32>),
+ ShowDerivationExit(Option<i32>),
#[error("Nix show-derivation command output contained an invalid UTF-8 sequence: {0}")]
- ShowDerivationUtf8Error(std::str::Utf8Error),
+ ShowDerivationUtf8(std::str::Utf8Error),
#[error("Failed to parse the output of nix show-derivation: {0}")]
- ShowDerivationParseError(serde_json::Error),
+ ShowDerivationParse(serde_json::Error),
#[error("Nix show-derivation output is empty")]
ShowDerivationEmpty,
#[error("Failed to run Nix build command: {0}")]
- BuildError(std::io::Error),
+ Build(std::io::Error),
#[error("Nix build command resulted in a bad exit code: {0:?}")]
- BuildExitError(Option<i32>),
+ BuildExit(Option<i32>),
#[error(
"Activation script deploy-rs-activate does not exist in profile.\n\
Did you forget to use deploy-rs#lib.<...>.activate.<...> on your profile path?"
@@ -34,13 +34,13 @@ pub enum PushProfileError {
Is there a mismatch in deploy-rs used in the flake you're deploying and deploy-rs command you're running?")]
ActivateRsDoesntExist,
#[error("Failed to run Nix sign command: {0}")]
- SignError(std::io::Error),
+ Sign(std::io::Error),
#[error("Nix sign command resulted in a bad exit code: {0:?}")]
- SignExitError(Option<i32>),
+ SignExit(Option<i32>),
#[error("Failed to run Nix copy command: {0}")]
- CopyError(std::io::Error),
+ Copy(std::io::Error),
#[error("Nix copy command resulted in a bad exit code: {0:?}")]
- CopyExitError(Option<i32>),
+ CopyExit(Option<i32>),
}
pub struct PushProfileData<'a> {
@@ -70,18 +70,18 @@ pub async fn push_profile(data: PushProfileData<'_>) -> Result<(), PushProfileEr
let show_derivation_output = show_derivation_command
.output()
.await
- .map_err(PushProfileError::ShowDerivationError)?;
+ .map_err(PushProfileError::ShowDerivation)?;
match show_derivation_output.status.code() {
Some(0) => (),
- a => return Err(PushProfileError::ShowDerivationExitError(a)),
+ a => return Err(PushProfileError::ShowDerivationExit(a)),
};
let derivation_info: HashMap<&str, serde_json::value::Value> = serde_json::from_str(
std::str::from_utf8(&show_derivation_output.stdout)
- .map_err(PushProfileError::ShowDerivationUtf8Error)?,
+ .map_err(PushProfileError::ShowDerivationUtf8)?,
)
- .map_err(PushProfileError::ShowDerivationParseError)?;
+ .map_err(PushProfileError::ShowDerivationParse)?;
let derivation_name = derivation_info
.keys()
@@ -127,11 +127,11 @@ pub async fn push_profile(data: PushProfileData<'_>) -> Result<(), PushProfileEr
.stdout(Stdio::null())
.status()
.await
- .map_err(PushProfileError::BuildError)?;
+ .map_err(PushProfileError::Build)?;
match build_exit_status.code() {
Some(0) => (),
- a => return Err(PushProfileError::BuildExitError(a)),
+ a => return Err(PushProfileError::BuildExit(a)),
};
if !Path::new(
@@ -172,11 +172,11 @@ pub async fn push_profile(data: PushProfileData<'_>) -> Result<(), PushProfileEr
.arg(&data.deploy_data.profile.profile_settings.path)
.status()
.await
- .map_err(PushProfileError::SignError)?;
+ .map_err(PushProfileError::Sign)?;
match sign_exit_status.code() {
Some(0) => (),
- a => return Err(PushProfileError::SignExitError(a)),
+ a => return Err(PushProfileError::SignExit(a)),
};
}
@@ -218,11 +218,11 @@ pub async fn push_profile(data: PushProfileData<'_>) -> Result<(), PushProfileEr
.env("NIX_SSHOPTS", ssh_opts_str)
.status()
.await
- .map_err(PushProfileError::CopyError)?;
+ .map_err(PushProfileError::Copy)?;
match copy_exit_status.code() {
Some(0) => (),
- a => return Err(PushProfileError::CopyExitError(a)),
+ a => return Err(PushProfileError::CopyExit(a)),
};
Ok(())