Document hooks events expressions (#1870)
Docs for https://github.com/roboll/helmfile/pull/882 Ref https://github.com/roboll/helmfile/issues/1868#issuecomment-854530386
This commit is contained in:
parent
1a109f7400
commit
0d4adfedab
34
README.md
34
README.md
|
|
@ -1143,6 +1143,40 @@ Now, replace `echo` with any command you like, and rewrite `args` that actually
|
|||
- linting
|
||||
- testing
|
||||
|
||||
Hooks expose additional template expressions:
|
||||
|
||||
`.Event.Name` is the name of the hook event.
|
||||
|
||||
`.Event.Error` is the error generated by a failed release, exposed for `posysync` hooks only when a release fails, otherwise its value is `nil`.
|
||||
|
||||
You can use the hooks event expressions to send notifications to platforms such as `Slack`, `MS Teams`, etc.
|
||||
|
||||
The following example passes arguments to a script which sends a notification:
|
||||
|
||||
```yaml
|
||||
releases:
|
||||
- name: myapp
|
||||
chart: mychart
|
||||
# *snip*
|
||||
hooks:
|
||||
- events:
|
||||
- presync
|
||||
- postsync
|
||||
showlogs: true
|
||||
command: notify.sh
|
||||
args:
|
||||
- --event
|
||||
- '{{`{{ .Event.Name }}`}}'
|
||||
- --status
|
||||
- '{{`{{ if .Event.Error }}failure{{ else }}success{{ end }}`}}'
|
||||
- --environment
|
||||
- '{{`{{ .Environment.Name }}`}}'
|
||||
- --namespace
|
||||
- '{{`{{ .Release.Namespace }}`}}'
|
||||
- --release
|
||||
- '{{`{{ .Release.Name }}`}}'
|
||||
```
|
||||
|
||||
For templating, imagine that you created a hook that generates a helm chart on-the-fly by running an external tool like ksonnet, kustomize, or your own template engine.
|
||||
It will allow you to write your helm releases with any language you like, while still leveraging goodies provided by helm.
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue