Skip to main content

Expressions

Expressions is a powerful tool that allows formulating complex filters for playbook events. Playbook event filters use Common Expression Language (CEL).

The Common Expression Language (CEL) is a non-Turing complete language designed for simplicity, speed, safety, and portability. CEL's C-like syntax looks nearly identical to equivalent expressions in C++, Go, Java, and TypeScript.

Examples:

notify-with-filter.yaml
---
apiVersion: mission-control.flanksource.com/v1
kind: Playbook
metadata:
name: notify-with-filter
spec:
on:
config:
- event: created
configs:
- type: Kubernetes::Pod
actions:
- name: Send notification
exec:
script: notify-send "{{.config.name}} was created"
- name: Bad script to create a failing action
exec:
script: non-existing-command
- name: Send all success notification
if: success() # this filter practically skips this action as the second action above always fails
exec:
script: notify-send "Everything went successfully"
- name: Send notification regardless
if: always()
exec:
script: notify-send "a config was created"

Context

FieldDescriptionSchema
configConfig passed to the playbookConfigItem
componentComponent passed to the playbookComponent
checkCanary Check passed to the playbookCheck
paramsUser provided parameters to the playbookmap[string]string