Skip to main content

Templating

Templating allows your playbook actions to work in context of a config, health check or a component.

Example:

scale-deployment.yaml
apiVersion: mission-control.flanksource.com/v1
kind: Playbook
metadata:
name: scale-deployment
spec:
description: Scale deployment
configs:
- type: Kubernetes::Deployment
tags:
environment: staging
parameters:
- name: replicas
label: The new desired number of replicas.
actions:
- name: 'scale deployment'
exec:
script: kubectl scale --replicas={{.params.replicas}} --namespace={{.config.tags.namespace}} deployment {{.config.name}}

Accessing results of another action

You can base your filters based on result of a previous action. The following two cel functions can be used:

getLastAction

getLastAction()

Syntax:

getLastAction().result.stdout.JSON().count < 5;

getAction

To fetch the result of any action that ran before this action, use getAction()

Syntax:

getAction('action_name').result.stdout.JSON().count < 5;

Context

Templates receive a context variable that contain details about the config or component it is running for. In addition, it also contains the optional params variable which contains the parameters passed to the playbook.

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
.user.nameName of the user who invoked the actionstring
.user.emailEmail of the user who invoked the actionstring
getLastAction()Returns the result of the action that just runAction Specific
getAction({action})Return the result of a specific actionAction Specific

Action Result

FieldDescriptionSchema
result.stdout