HTTPWebhook
HTTPWebhook
defines a webhook which can be triggered by HTTP JSON API.
#
Modelspec.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 ofcreate
andupdate
. 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#
RequestHeaders
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. |
#
ResponseResponse 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
HTTPWebhook
not found.- Request body is invalid.
data
does not matchspec.schema
.
403 Forbidden
spec.secretToken
is specified, but the secret or its key does not exist.Pullup-Webhook-Secret
does not matchspec.secretToken
.
#
Examples#
BasicThis 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 WebhookWhen 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 DataTransform input data before executing triggers. The following example will swap abc
and xyz
keys in input data.