Working with context
Keep uses Mustache syntax to inject context at runtime, supporting functions, dictionaries, lists, and nested access.
Here are some examples:
{{ steps.step-id.results }}
- Result of step-idkeep.len({{ steps.step-id.results }})
- Number of results from step-id{{ steps.this.results[0] }}
- First result of this stepkeep.first({{ steps.this.results }})
- First result (equivalent to the previous example){{ steps.step-id.results[0][0] }}
- First item of the first result
If you have suggestions/improvements/bugs for Keep’s syntax, please open feature request and get eternal glory.
Special context
Keep provides two special context containers - providers
and steps
Providers
Provider configuration typically look like:
Here, {{ providers.mysql-prod }}
is dynamically translated at runtime from the providers.yaml file.
Steps
The output of steps can be accessed from anywhere in the YAML using {{ steps.step-name.results }}
. This output can be used in conditions, actions, or any other place.
Functions
Keep’s syntax allow to use functions on context blocks. For example, keep.len({{ steps.step-name.results }})
will return the number of results of step-name
step.
Under the hood, Keep uses Python’s ast
module to parse these expressions and evaluate them as best as possible.