diff --git a/README.md b/README.md index 0f19443c..e401650f 100644 --- a/README.md +++ b/README.md @@ -714,8 +714,9 @@ Once `events` are triggered, associated `hooks` are executed, by running the `co Currently supported `events` are: - `prepare` -- `cleanup` - `presync` +- `postsync` +- `cleanup` Hooks associated to `prepare` events are triggered after each release in your helmfile is loaded from YAML, before execution. @@ -723,6 +724,8 @@ Hooks associated to `cleanup` events are triggered after each release is process Hooks associated to `presync` events are triggered before each release is applied to the remote cluster. This is the ideal event to execute any commands that may mutate the cluster state as it will not be run for read-only operations like `lint`, `diff` or `template`. +Hooks associated to `postsync` events are triggered after each release is applied to the remote cluster. This is the ideal event to execute any commands that may mutate the cluster state as it will not be run for read-only operations like `lint`, `diff` or `template`. + The following is an example hook that just prints the contextual information provided to hook: ``` diff --git a/state/state.go b/state/state.go index 80ca3e66..6dbac87a 100644 --- a/state/state.go +++ b/state/state.go @@ -374,7 +374,11 @@ func (st *HelmState) SyncReleases(affectedReleases *AffectedReleases, helm helme results <- syncResult{errors: []*ReleaseError{relErr}} } - if _, err := st.triggerCleanupEvent(prep.release, "sync"); err != nil { + if _, err := st.triggerPostsyncEvent(release, "sync"); err != nil { + st.logger.Warnf("warn: %v\n", err) + } + + if _, err := st.triggerCleanupEvent(release, "sync"); err != nil { st.logger.Warnf("warn: %v\n", err) } } @@ -938,6 +942,10 @@ func (st *HelmState) triggerPresyncEvent(r *ReleaseSpec, helmfileCommand string) return st.triggerReleaseEvent("presync", r, helmfileCommand) } +func (st *HelmState) triggerPostsyncEvent(r *ReleaseSpec, helmfileCommand string) (bool, error) { + return st.triggerReleaseEvent("postsync", r, helmfileCommand) +} + func (st *HelmState) triggerReleaseEvent(evt string, r *ReleaseSpec, helmfileCmd string) (bool, error) { bus := &event.Bus{ Hooks: r.Hooks,