feat: add webhooks for major events: clone creation, etc. (#514)
Description
Add webhooks for major events
- Extend DLE config to support webhooks (clone_create, clone_reset, clone_delete)
- Support webhook configuration reloading
- Make requests and report status and response to logs
- Filter webhook secrets in logs
Related issue
Examples
Configuration
webhooks:
hooks:
- url: "http://127.0.0.1:2345/healthz"
secret: "secret-token"
trigger:
- clone_create
- clone_reset
Basic Payload
{
event_type string
entity_id string
}
Clone Payload
{
event_type string
entity_id string
host string
port uint
username string
dbname string
}
Logs output
2023/05/25 18:40:58 webhooks.go:107: [DEBUG] Trigger event: {{clone_create chnqnem1q2ss73bt6i5g} localhost 6000 john postgres}
2023/05/25 18:40:58 webhooks.go:116: [INFO] Webhook request: http://127.0.0.1:2345/healthz
2023/05/25 18:40:58 webhooks.go:142: [DEBUG] Webhook Payload: {"event_type":"clone_create","entity_id":"chnqnem1q2ss73bt6i5g","host":"localhost","port":6000,"username":"john","dbname":"postgres"}
2023/05/25 18:40:58 logging.go:16: [INFO] -> POST /healthz
2023/05/25 18:40:58 webhooks.go:125: [DEBUG] Webhook status code: 200
2023/05/25 18:40:58 webhooks.go:133: [DEBUG] Webhook response: {"version":"v3.4.0-rc.5-34-g1e790c9f-20230525-1840","edition":"community","instanceID":"cdhk35u1q2ss73eqa0ng"}
...
2023/05/25 18:41:39 webhooks.go:107: [DEBUG] Trigger event: {{clone_reset chnqnem1q2ss73bt6i5g} localhost 6000 john postgres}
2023/05/25 18:41:39 webhooks.go:116: [INFO] Webhook request: http://127.0.0.1:2345/healthz
2023/05/25 18:41:39 webhooks.go:142: [DEBUG] Webhook Payload: {"event_type":"clone_reset","entity_id":"chnqnem1q2ss73bt6i5g","host":"localhost","port":6000,"username":"john","dbname":"postgres"}
2023/05/25 18:41:39 logging.go:16: [INFO] -> POST /healthz
2023/05/25 18:41:39 webhooks.go:125: [DEBUG] Webhook status code: 200
2023/05/25 18:41:39 webhooks.go:133: [DEBUG] Webhook response: {"version":"v3.4.0-rc.5-34-g1e790c9f-20230525-1840","edition":"community","instanceID":"cdhk35u1q2ss73eqa0ng"}
Checklist
-
MR description has been reviewed -
MR changes are functionally tested -
MR does NOT have API/CLI changes OR there are API/CLI changes and they have been reviewed & DOCS ARE ADJUSTED (reference doc, etc) -
MR does NOT have UI changes OR there are UI changes and they have been reviewed & UX IS REVIEWED
Closes #514
Edited by Nikolay Samokhvalov