HTTPWebhook
HTTPWebhook defines a webhook which can be triggered by HTTP JSON API.
Model#
spec.triggers#
Required
Trigger to execute when the webhook is triggered. The value is an array of objects containing the following fields.
| Key | Type | Description |
|---|---|---|
name Required | string | Name of Trigger. |
namespace | string | Namespace of Trigger. By default, this value will be the same as the webhook namespace. |
transform | unknown | Transform input events before executing Trigger. |
You can use Go template string in the transform field. The following are the available variables.
| Key | Type | Description |
|---|---|---|
trigger | Trigger | Current Trigger resource. |
event | unknown | Input event. |
spec.action#
The action to execute. It must be one of the following values.
create- Create resources if not exist yet.update- Update resources if already exist.apply- Mix ofcreateandupdate. Create resources if not exist or update otherwise.delete- Delete resources.
You can use Go template string in this value. The following are the available variables.
| Key | Type | Description |
|---|---|---|
event | unknown | Input event. |
action | string | Default action defined by the webhook handler. |
spec.schema#
The JSON schema for input events. See Trigger for more info.
spec.secretToken#
The secret token to use in webhook requests. Pullup-Webhook-Secret header is required for webhook requests if a secret token is specified.
Example:
API#
Request#
Headers
| Key | Description |
|---|---|
Content-Type | Must be application/json. |
Pullup-Webhook-Secret | This header is required when spec.secretToken is specified. |
Body
| Key | Type | Description |
|---|---|---|
name Required | string | Name of HTTPWebhook. |
namespace Required | string | Namespace of HTTPWebhook. |
action Required | string | The action to execute. This value will be used as action variable in spec.action template string. |
data | unknown | Input data. If spec.schema is specified, the value will be validated before executing triggers. |
Response#
Response body is a JSON. When requests are successful, the error array will be omitted from the response body.
200 OK
- Triggers are executed successfully.
400 Bad Request
HTTPWebhooknot found.- Request body is invalid.
datadoes not matchspec.schema.
403 Forbidden
spec.secretTokenis specified, but the secret or its key does not exist.Pullup-Webhook-Secretdoes not matchspec.secretToken.
Examples#
Basic#
This is the most basic usage of the HTTPWebhook resource. When the following webhook is triggered, the triggers specified in spec.triggers will be executed.
Specify Action in Webhook#
When spec.action is specified, its value will override action sent in the request body. You can access the action in request body via the {{ .action }} variable.
Validate Input Data#
Secret Token#
Transform Input Data#
Transform input data before executing triggers. The following example will swap abc and xyz keys in input data.