Skip to content

Commit 390aea6

Browse files
committed
Refactor merge DeployDefs into DeployData (single view)
1 parent 7cd09ef commit 390aea6

File tree

4 files changed

+19
-19
lines changed

4 files changed

+19
-19
lines changed

src/cli.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ pub enum RunDeployError {
168168
ResolveTarget(#[from] data::ResolveTargetError),
169169

170170
#[error("Error processing deployment definitions: {0}")]
171-
DeployDataDefs(#[from] data::DeployDataDefsError),
171+
DeployDataError(#[from] data::DeployDataError),
172172
#[error("Failed to make printable TOML of deployment: {0}")]
173173
TomlFormat(#[from] toml::ser::Error),
174174
#[error("{0}")]

src/data.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,14 @@ pub struct DeployData<'a> {
265265
pub merged_settings: settings::GenericSettings,
266266
}
267267

268+
#[derive(Error, Debug)]
269+
pub enum DeployDataError {
270+
#[error("Neither `user` nor `sshUser` are set for profile {0} of node {1}")]
271+
NoProfileUser(String, String),
272+
#[error("Value `hostname` is not define for profile {0} of node {1}")]
273+
NoProfileHost(String, String),
274+
}
275+
268276
#[derive(Clap, Debug, Clone)]
269277
pub struct Flags {
270278
/// Check signatures when using `nix copy`
@@ -310,14 +318,6 @@ pub struct DeployDefs {
310318
pub sudo: Option<String>,
311319
}
312320

313-
#[derive(Error, Debug)]
314-
pub enum DeployDataDefsError {
315-
#[error("Neither `user` nor `sshUser` are set for profile {0} of node {1}")]
316-
NoProfileUser(String, String),
317-
#[error("Value `hostname` is not define for profile {0} of node {1}")]
318-
NoProfileHost(String, String),
319-
}
320-
321321
impl<'a> DeployData<'a> {
322322

323323
fn new(
@@ -352,7 +352,7 @@ impl<'a> DeployData<'a> {
352352
}
353353
}
354354

355-
pub fn defs(&'a self) -> Result<DeployDefs, DeployDataDefsError> {
355+
pub fn defs(&'a self) -> Result<DeployDefs, DeployDataError> {
356356
let ssh_user = match self.merged_settings.ssh_user {
357357
Some(ref u) => u.clone(),
358358
None => whoami::username(),
@@ -375,7 +375,7 @@ impl<'a> DeployData<'a> {
375375
})
376376
}
377377

378-
pub fn ssh_uri(&'a self) -> Result<String, DeployDataDefsError> {
378+
pub fn ssh_uri(&'a self) -> Result<String, DeployDataError> {
379379

380380
let hostname = match self.hostname {
381381
Some(x) => x,
@@ -390,7 +390,7 @@ impl<'a> DeployData<'a> {
390390
}
391391

392392
// can be dropped once ssh fully supports ipv6 uris
393-
pub fn ssh_non_uri(&'a self) -> Result<String, DeployDataDefsError> {
393+
pub fn ssh_non_uri(&'a self) -> Result<String, DeployDataError> {
394394

395395
let hostname = match self.hostname {
396396
Some(x) => x,
@@ -408,7 +408,7 @@ impl<'a> DeployData<'a> {
408408
self.merged_settings.ssh_opts.iter()
409409
}
410410

411-
pub fn get_profile_path(&'a self) -> Result<String, DeployDataDefsError> {
411+
pub fn get_profile_path(&'a self) -> Result<String, DeployDataError> {
412412
let profile_user = self.get_profile_user()?;
413413
let profile_path = match self.profile.profile_settings.profile_path {
414414
None => match &profile_user[..] {
@@ -423,13 +423,13 @@ impl<'a> DeployData<'a> {
423423
Ok(profile_path)
424424
}
425425

426-
pub fn get_profile_user(&'a self) -> Result<String, DeployDataDefsError> {
426+
pub fn get_profile_user(&'a self) -> Result<String, DeployDataError> {
427427
let profile_user = match self.merged_settings.user {
428428
Some(ref x) => x.clone(),
429429
None => match self.merged_settings.ssh_user {
430430
Some(ref x) => x.clone(),
431431
None => {
432-
return Err(DeployDataDefsError::NoProfileUser(
432+
return Err(DeployDataError::NoProfileUser(
433433
self.profile_name.to_owned(),
434434
self.node_name.to_owned(),
435435
))

src/deploy.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ pub enum ConfirmProfileError {
206206
SSHConfirmExitError(Option<i32>),
207207

208208
#[error("Deployment data invalid: {0}")]
209-
InvalidDeployDataDefsError(#[from] data::DeployDataDefsError),
209+
InvalidDeployDataError(#[from] data::DeployDataError),
210210
}
211211

212212
pub async fn confirm_profile(
@@ -265,7 +265,7 @@ pub enum DeployProfileError {
265265
ConfirmError(#[from] ConfirmProfileError),
266266

267267
#[error("Deployment data invalid: {0}")]
268-
InvalidDeployDataDefsError(#[from] data::DeployDataDefsError),
268+
InvalidDeployDataError(#[from] data::DeployDataError),
269269
}
270270

271271
pub async fn deploy_profile(
@@ -404,7 +404,7 @@ pub enum RevokeProfileError {
404404
SSHRevokeExitError(Option<i32>),
405405

406406
#[error("Deployment data invalid: {0}")]
407-
InvalidDeployDataDefsError(#[from] data::DeployDataDefsError),
407+
InvalidDeployDataError(#[from] data::DeployDataError),
408408
}
409409
pub async fn revoke(
410410
deploy_data: &data::DeployData<'_>,

src/push.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ pub enum PushProfileError {
4545
CopyExitError(Option<i32>),
4646

4747
#[error("Deployment data invalid: {0}")]
48-
InvalidDeployDataDefsError(#[from] data::DeployDataDefsError),
48+
InvalidDeployDataError(#[from] data::DeployDataError),
4949
}
5050

5151
pub struct PushProfileData<'a> {

0 commit comments

Comments
 (0)