Skip to content

Commit

Permalink
Change name to PackageMaintenanceHookExt
Browse files Browse the repository at this point in the history
Signed-off-by: David McNeil <mcneil.david2@gmail.com>
  • Loading branch information
davidMcneil committed Jul 8, 2020
1 parent 65495b5 commit c02acae
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
4 changes: 2 additions & 2 deletions components/common/src/command/package/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ use crate::{api_client::{self,
Error::APIError},
error::{Error,
Result},
templating::hooks::{HookExt,
InstallHook},
templating::hooks::{InstallHook,
PackageMaintenanceHookExt},
ui::{Status,
UIWriter}};
use habitat_core::{self,
Expand Down
12 changes: 10 additions & 2 deletions components/common/src/templating/hooks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -320,8 +320,16 @@ pub trait Hook: fmt::Debug + Sized + Send {
fn stderr_log_path(&self) -> &Path;
}

/// A trait that adds a convenient method for executing one-off hooks
///
/// This trait unifies the logic the `install` and `uninstall` hooks use to execute. These hooks
/// are unique in that they are run in a one-off fashion opposed to running as part of a service
/// lifecycle.
///
/// In future refactoring of the `Hook` trait this should probably be integrated into that trait
/// directly.
#[async_trait::async_trait]
pub trait HookExt: Hook<ExitValue = ExitStatus> + Sync {
pub trait PackageMaintenanceHookExt: Hook<ExitValue = ExitStatus> + Sync {
/// A high level hook operation that adds the following conveniences around `Hook::run`:
///
/// * find the hook in a given `PackageInstall`
Expand Down Expand Up @@ -373,7 +381,7 @@ pub trait HookExt: Hook<ExitValue = ExitStatus> + Sync {
}
}

impl<T: Hook<ExitValue = ExitStatus> + Sync> HookExt for T {}
impl<T: Hook<ExitValue = ExitStatus> + Sync> PackageMaintenanceHookExt for T {}

#[derive(Debug, Serialize)]
pub struct InstallHook {
Expand Down
2 changes: 1 addition & 1 deletion components/hab/src/command/pkg/uninstall/uninstall_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::{command::pkg::list,
Result}};
use futures::stream::StreamExt;
use habitat_common::{package_graph::PackageGraph,
templating::hooks::{HookExt,
templating::hooks::{PackageMaintenanceHookExt,
UninstallHook},
types::ListenCtlAddr,
ui::{Status,
Expand Down

0 comments on commit c02acae

Please sign in to comment.