mirror of
https://github.com/serokell/deploy-rs.git
synced 2024-09-11 10:45:29 +03:00
Merge pull request #274 from PhilTaken/phil/node-name-in-errors
better error messages: provide node names
This commit is contained in:
commit
ea0aaeb222
36
src/cli.rs
36
src/cli.rs
@ -380,10 +380,12 @@ fn prompt_deployment(
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
pub enum RunDeployError {
|
||||
#[error("Failed to deploy profile: {0}")]
|
||||
DeployProfile(#[from] deploy::deploy::DeployProfileError),
|
||||
#[error("Failed to push profile: {0}")]
|
||||
PushProfile(#[from] deploy::push::PushProfileError),
|
||||
#[error("Failed to deploy profile to node {0}: {1}")]
|
||||
DeployProfile(String, deploy::deploy::DeployProfileError),
|
||||
#[error("Failed to build profile on node {0}: {0}")]
|
||||
BuildProfile(String, deploy::push::PushProfileError),
|
||||
#[error("Failed to push profile to node {0}: {0}")]
|
||||
PushProfile(String, deploy::push::PushProfileError),
|
||||
#[error("No profile named `{0}` was found")]
|
||||
ProfileNotFound(String),
|
||||
#[error("No node named `{0}` was found")]
|
||||
@ -396,10 +398,10 @@ pub enum RunDeployError {
|
||||
TomlFormat(#[from] toml::ser::Error),
|
||||
#[error("{0}")]
|
||||
PromptDeployment(#[from] PromptDeploymentError),
|
||||
#[error("Failed to revoke profile: {0}")]
|
||||
RevokeProfile(#[from] deploy::deploy::RevokeProfileError),
|
||||
#[error("Deployment failed, rolled back to previous generation")]
|
||||
Rollback
|
||||
#[error("Failed to revoke profile for node {0}: {1}")]
|
||||
RevokeProfile(String, deploy::deploy::RevokeProfileError),
|
||||
#[error("Deployment to node {0} failed, rolled back to previous generation")]
|
||||
Rollback(String)
|
||||
}
|
||||
|
||||
type ToDeploy<'a> = Vec<(
|
||||
@ -586,11 +588,17 @@ async fn run_deploy(
|
||||
};
|
||||
|
||||
for data in data_iter() {
|
||||
deploy::push::build_profile(data).await?;
|
||||
let node_name: String = data.deploy_data.node_name.to_string();
|
||||
deploy::push::build_profile(data).await.map_err(|e| {
|
||||
RunDeployError::BuildProfile(node_name, e)
|
||||
})?;
|
||||
}
|
||||
|
||||
for data in data_iter() {
|
||||
deploy::push::push_profile(data).await?;
|
||||
let node_name: String = data.deploy_data.node_name.to_string();
|
||||
deploy::push::push_profile(data).await.map_err(|e| {
|
||||
RunDeployError::PushProfile(node_name, e)
|
||||
})?;
|
||||
}
|
||||
|
||||
let mut succeeded: Vec<(&deploy::DeployData, &deploy::DeployDefs)> = vec![];
|
||||
@ -613,12 +621,14 @@ async fn run_deploy(
|
||||
// the command line)
|
||||
for (deploy_data, deploy_defs) in &succeeded {
|
||||
if deploy_data.merged_settings.auto_rollback.unwrap_or(true) {
|
||||
deploy::deploy::revoke(*deploy_data, *deploy_defs).await?;
|
||||
deploy::deploy::revoke(*deploy_data, *deploy_defs).await.map_err(|e| {
|
||||
RunDeployError::RevokeProfile(deploy_data.node_name.to_string(), e)
|
||||
})?;
|
||||
}
|
||||
}
|
||||
return Err(RunDeployError::Rollback);
|
||||
return Err(RunDeployError::Rollback(deploy_data.node_name.to_string()));
|
||||
}
|
||||
return Err(RunDeployError::DeployProfile(e))
|
||||
return Err(RunDeployError::DeployProfile(deploy_data.node_name.to_string(), e))
|
||||
}
|
||||
succeeded.push((deploy_data, deploy_defs))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user