https://github.com/spoonboy-io/dozer
Morpheus Processes with Webhooks
https://github.com/spoonboy-io/dozer
events golang morpheus processes webhooks
Last synced: about 2 months ago
JSON representation
Morpheus Processes with Webhooks
- Host: GitHub
- URL: https://github.com/spoonboy-io/dozer
- Owner: spoonboy-io
- License: mpl-2.0
- Created: 2022-05-24T11:00:38.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2024-02-13T18:29:09.000Z (about 2 years ago)
- Last Synced: 2024-06-20T00:28:00.446Z (almost 2 years ago)
- Topics: events, golang, morpheus, processes, webhooks
- Language: Go
- Homepage:
- Size: 5.49 MB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Dozer
## Morpheus Processes with Webhooks
[](https://go.dev/)
[](https://goreportcard.com/report/github.com/spoonboy-io/dozer)
[](https://github.com/spoonboy-io/dozer/actions/workflows/build.yml)
[](https://github.com/spoonboy-io/dozer/actions/workflows/unit_test.yml)
[](https://github.com/spoonboy-io/dozer/releases)
[](https://github.com/spoonboy-io/dozer/commits)
[](LICENSE)
## About
Dozer watches [Morpheus CMP](https://morpheusdata.com) processes/events.
It will notify external applications of Morpheus events
via HTTP request (webhook) based on YAML configuration you specify.
## Releases
You can find the [latest software here](https://github.com/spoonboy-io/dozer/releases/latest).
### Get Started
Dozer polls the Morpheus database so needs credentials. The `morpheus` user can be used, but it is preferable to
create an additional user with SELECT privileges on the `process` and `process_type` tables.
A `mysql.env` file should be created in the same directory as the application from which the database user configuration
will be read. The following example shows the environment variables used by Dozer which should be included in `mysql.env`:
```bash
## MySQL Config
MYSQL_SERVER=127.0.0.1
MYSQL_USER=dozer
MYSQL_PASSWORD=xxxxa8aca0de5dab5fa1bxxxxx
## Optional to override defaults
MYSQL_DATABASE=morpheus
POLL_INTERVAL_SECONDS=3
```
### Webhook Configuration
Webhooks and their triggers are configured in a YAML file `webhook.yaml` which should reside in the same directory
as the Dozer application. An example configuration, showing a single Webhook is shown below:
```YAML
---
- webhook:
description: Hook example with trigger that runs when status is `complete`
url: https://webhook-endpoint.com
method: POST
requestBody: |
{
"id": {{.Id}},
"updatedBy": "{{.UpdatedBy}}",
"status": "{{.Status}}"
}
token: BEARER xxxxxxxxxxxxxx
triggers:
status: complete
```
GET and POST methods are supported. If POST method Dozer will look for `requestBody`.
If `token` is supplied it will be sent in the AUTHORIZATION header.
Variables which contain information about the Morpheus process can be interpolated in the `requestBody` using the standard Golang
templating format. A complete list can be found [here](https://github.com/spoonboy-io/dozer/blob/master/internal/hook/send.go#L15).
### Triggers
Currently, Webhook triggers can be specified on `status`, `processType`, `taskName`, `accountId` and `createdBy`. They are
evaluated on processes which have finished running, not in-progress processes. Triggers are additive - all conditions must
be satisfied for the Webhook to fire.
| Trigger | Description | YAML Example |
|--------- |------------- | --------- |
| `status` | Runs when the process is complete or failed | `status: failed` |
| `processType` | Runs for a specific process type ([see list here](https://github.com/spoonboy-io/dozer/blob/master/internal/morpheus/processType.go#L11)) | `processType: localWorkflow` |
| `taskName` | Runs for a given task name | `taskName: Hello World` |
| `accountId` | Runs for specific tenant id | `accountId: 2` |
| `createdBy` | Runs for processes created by a specific user | `createdBy: admin` |
### Installation
Grab the tar.gz or zip archive for your OS from the [releases page](https://github.com/spoonboy-io/dozer/releases/latest).
Unpack it to the target host, and then start the server.
```
./dozer
```
Or with nohup..
```
nohup ./dozer &
```
### Development Opportunities
- Add more triggers such as `zoneId`, `instanceName`, `appName`, `containerName`
- Retry and blacklisting for webhooks that fail
- Other notification mechanisms such as email or messaging protocol
- Run as a service
### License
Licensed under [Mozilla Public License 2.0](LICENSE)