Skip to content

Commit

Permalink
[master] Format markdown
Browse files Browse the repository at this point in the history
Produced via:
  `prettier --write --prose-wrap=always $(find -name '*.md' | grep -v vendor | grep -v .github | grep -v docs/cmd/)`
/assign ImJasonH dibyom
/cc ImJasonH dibyom
  • Loading branch information
mattmoor authored and tekton-robot committed Mar 23, 2020
1 parent adddb0f commit a9704de
Showing 1 changed file with 26 additions and 17 deletions.
43 changes: 26 additions & 17 deletions docs/eventlisteners.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ EventListener sink uses to create the Tekton resources. The ServiceAccount needs
a role with the following rules:

<!-- FILE: examples/role-resources/triggerbinding-roles/role.yaml -->

```YAML
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
Expand All @@ -91,7 +92,6 @@ rules:
verbs: ["create"]
```


If your EventListener is using
[`ClusterTriggerBindings`](./clustertriggerbindings.md), you'll need a
ServiceAccount with a
Expand Down Expand Up @@ -200,6 +200,7 @@ if desired. The response body and headers of the last Interceptor is used for
resource binding/templating.

<!-- FILE: examples/eventlisteners/eventlistener-interceptor.yaml -->

```YAML
---
apiVersion: tekton.dev/v1alpha1
Expand Down Expand Up @@ -230,7 +231,6 @@ spec:
name: pipeline-template
```


### GitHub Interceptors

GitHub Interceptors contain logic to validate and filter webhooks that come from
Expand All @@ -252,6 +252,7 @@ The body/header of the incoming request will be preserved in this Interceptor's
response.

<!-- FILE: examples/eventlisteners/github-eventlistener-interceptor.yaml -->

```YAML
---
apiVersion: tekton.dev/v1alpha1
Expand All @@ -275,7 +276,6 @@ spec:
name: pipeline-template
```


### GitLab Interceptors

GitLab Interceptors contain logic to validate and filter requests that come from
Expand Down Expand Up @@ -322,10 +322,11 @@ spec:
### CEL Interceptors

CEL Interceptors can be used to filter or modify incoming events, using the
[CEL](https://github.com/google/cel-go) expression language.
[CEL](https://github.com/google/cel-go) expression language.

Please read the [cel-spec language definition](https://github.com/google/cel-spec/blob/master/doc/langdef.md) for
more details on the expression language syntax.
Please read the
[cel-spec language definition](https://github.com/google/cel-spec/blob/master/doc/langdef.md)
for more details on the expression language syntax.

The `cel-trig-with-matches` trigger below filters events that don't have an
`'X-GitHub-Event'` header matching `'pull_request'`.
Expand All @@ -334,6 +335,7 @@ It also modifies the incoming request, adding an extra key to the JSON body,
with a truncated string coming from the hook body.

<!-- FILE: examples/eventlisteners/cel-eventlistener-interceptor.yaml -->

```YAML
apiVersion: tekton.dev/v1alpha1
kind: EventListener
Expand Down Expand Up @@ -364,12 +366,14 @@ spec:
```

In addition to the standard expressions provided by CEL, Triggers supports some
useful functions for dealing with event data [CEL expressions](./cel_expressions.md).
useful functions for dealing with event data
[CEL expressions](./cel_expressions.md).

The body/header of the incoming request will be preserved in this Interceptor's
response.

<!-- FILE: examples/eventlisteners/cel-eventlistener-interceptor.yaml -->

```YAML
apiVersion: tekton.dev/v1alpha1
kind: EventListener
Expand Down Expand Up @@ -399,14 +403,14 @@ spec:
name: pipeline-template
```


The `filter` expression must return a `true` value if this trigger is to
be processed, and the `overlays` applied.
The `filter` expression must return a `true` value if this trigger is to be
processed, and the `overlays` applied.

Optionally, no `filter` expression can be provided, and the `overlays` will be
applied to the incoming body.

<!-- FILE: examples/eventlisteners/cel-eventlistener-no-filter.yaml -->

```YAML
apiVersion: tekton.dev/v1alpha1
kind: EventListener
Expand All @@ -427,13 +431,13 @@ spec:
name: pipeline-template
```


#### Overlays

The CEL interceptor supports "overlays", these are CEL expressions that are
applied to the body before it's returned to the event-listener.

<!-- FILE: examples/eventlisteners/cel-eventlistener-multiple-overlays.yaml -->

```YAML
apiVersion: tekton.dev/v1alpha1
kind: EventListener
Expand All @@ -459,12 +463,13 @@ spec:
In this example, the bindings will see two additional fields:

Assuming that the input body looked something like this:

```json
{
"ref": "refs/heads/master",
"pull_request": {
"head": {
"sha": "6113728f27ae82c7b1a177c8d03f9e96e0adf246",
"sha": "6113728f27ae82c7b1a177c8d03f9e96e0adf246"
}
}
}
Expand All @@ -477,24 +482,26 @@ The output body would look like this:
"ref": "refs/heads/master",
"pull_request": {
"head": {
"sha": "6113728f27ae82c7b1a177c8d03f9e96e0adf246",
},
"sha": "6113728f27ae82c7b1a177c8d03f9e96e0adf246"
}
},
"extensions": {
"truncated_sha": "6113728",
"branch_name": "master"
}
}
```
The `key` element of the overlay can create new elements in a body, or,
overlay existing elements.

The `key` element of the overlay can create new elements in a body, or, overlay
existing elements.

For example, this expression:

```YAML
- key: body.pull_request.head.short_sha
expression: "truncate(body.pull_request.head.sha, 7)"
```

Would see the `short_sha` being inserted into the existing body:

```json
Expand All @@ -504,16 +511,18 @@ Would see the `short_sha` being inserted into the existing body:
"head": {
"sha": "6113728f27ae82c7b1a177c8d03f9e96e0adf246",
"short_sha": "6113728"
},
}
}
}
```

It's even possible to replace existing fields, by providing a key that matches
the path to an existing value.

Anything that is applied as an overlay can be extracted using a binding e.g.

<!-- FILE: examples/triggerbindings/cel-example-trigger-binding.yaml -->

```YAML
apiVersion: tekton.dev/v1alpha1
kind: TriggerBinding
Expand Down

0 comments on commit a9704de

Please sign in to comment.