Jinja2 for rendering Webhook dynamic variables
What does this MR do and why?
Implement Jinja2 Template Rendering for ther Crafty Webhook System
Deliverables:
-
Base Webhook implementation (Starting with Discord). -
Populate callback func's, avail event data on call back from factory get_monitored_events() -
Achieve majority of dynamic variables in scoping issue. -
Replicate over all available webhook providers -
Crafty Configuration option for base url, used in webhook links -
Docs Detailing available jinja variables, examples (make sure the version tag) crafty-documentation@e159ce66 -
Frontend display link to Crafty Jinja2 docs.
Resolves: #296 (closed)
Jinja Variable Support Matrix (taken from user feat request)
Below is the original table the user had of suggestions, and what I have been able to fulfil so far
x = suggested to consider
| Description | Variable | Server Start | Server Stop | Server Crash | Server Killed | Command Sent | Backup Successful |
|---|---|---|---|---|---|---|---|
| General Variables | |||||||
| Server Name | server_name |
||||||
| Server ID | server_id |
||||||
| Event Type (useful for making a single webhook for multiple events) | event_type |
||||||
| What triggered this event? (user triggered, schedule triggered, backup triggered) | source_type |
||||||
| ID of source that triggered the event (e.g. username) | source_id |
||||||
| Name of source that triggered the event (username) | source_name |
||||||
| ISO 8601 formatted datetime | time_iso |
||||||
| UNIX timestamp (useful for Discord) | time_unix |
||||||
| Day/Month/Year in UTC | time_[day|month|year] |
||||||
| Event Specific Variables | |||||||
| Crash Reason/Kill Signal | reason |
||||||
| Command sent | command |
||||||
| Backup file name | backup_name |
||||||
| Backup file download link | backup_link |
||||||
| Backup file size | backup_size |
||||||
| Backup Status (Wither the backup succeeded/failed) | backup_status |
||||||
| Backup Error (The error of a failed backup) | backup_error |
How to set up and validate locally
Starter Crafty Instance on this branch and try using ginger syntax with the available variables above in the webhook body content.
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
Have you checked this doesn't interfere/conflict/duplicate someone elses work? -
Have you fully tested your changes? -
Have you resolved any lint issues? -
Have you assigned a reviewer? -
Have you applied correct labels?
Edited by Iain Powrie