Skip to main content
Version: 1.0

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.

KeyTypeDescription
name RequiredstringName of Trigger.
namespacestringNamespace of Trigger. By default, this value will be the same as the webhook namespace.
transformunknownTransform input events before executing Trigger.

You can use Go template string in the transform field. The following are the available variables.

KeyTypeDescription
triggerTriggerCurrent Trigger resource.
eventunknownInput 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 of create and update. 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.

KeyTypeDescription
eventunknownInput event.
actionstringDefault 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:

secretToken:
secretKeyRef:
name: example
key: secret

API#

Request#

POST /webhooks/http

Headers

KeyDescription
Content-TypeMust be application/json.
Pullup-Webhook-SecretThis header is required when spec.secretToken is specified.

Body

KeyTypeDescription
name RequiredstringName of HTTPWebhook.
namespace RequiredstringNamespace of HTTPWebhook.
action RequiredstringThe action to execute. This value will be used as action variable in spec.action template string.
dataunknownInput 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.

{
"errors": [
{
"type": "",
"description": "",
"field": ""
}
]
}

200 OK

  • Triggers are executed successfully.

400 Bad Request

  • HTTPWebhook not found.
  • Request body is invalid.
  • data does not match spec.schema.

403 Forbidden

  • spec.secretToken is specified, but the secret or its key does not exist.
  • Pullup-Webhook-Secret does not match spec.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.

apiVersion: pullup.dev/v1beta1
kind: HTTPWebhook
metadata:
name: example
spec:
triggers:
- name: example

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.

apiVersion: pullup.dev/v1beta1
kind: HTTPWebhook
metadata:
name: example
spec:
action: "{{ if .event.deleted }}delete{{ else }}{{ .action }}{{ end }}"
triggers:
- name: example

Validate Input Data#

apiVersion: pullup.dev/v1beta1
kind: HTTPWebhook
metadata:
name: example
spec:
triggers:
- name: example
schema:
type: object
properties:
suffix:
type: string
version:
type: string

Secret Token#

apiVersion: pullup.dev/v1beta1
kind: HTTPWebhook
metadata:
name: example
spec:
triggers:
- name: example
secretToken:
secretKeyRef:
name: example
key: secret

Transform Input Data#

Transform input data before executing triggers. The following example will swap abc and xyz keys in input data.

apiVersion: pullup.dev/v1beta1
kind: HTTPWebhook
metadata:
name: example
spec:
triggers:
- name: example
transform:
abc: "{{ .event.xyz }}"
xyz: "{{ .event.abc }}"