From a9704de9cd2ef6f9c0308f51b02a3738977964cb Mon Sep 17 00:00:00 2001 From: "Matt Moore (via sockpuppet)" Date: Mon, 23 Mar 2020 14:02:04 +0000 Subject: [PATCH] [master] Format markdown 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 --- docs/eventlisteners.md | 43 +++++++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/docs/eventlisteners.md b/docs/eventlisteners.md index a93ac4e8d..746285b1b 100644 --- a/docs/eventlisteners.md +++ b/docs/eventlisteners.md @@ -72,6 +72,7 @@ EventListener sink uses to create the Tekton resources. The ServiceAccount needs a role with the following rules: + ```YAML kind: Role apiVersion: rbac.authorization.k8s.io/v1 @@ -91,7 +92,6 @@ rules: verbs: ["create"] ``` - If your EventListener is using [`ClusterTriggerBindings`](./clustertriggerbindings.md), you'll need a ServiceAccount with a @@ -200,6 +200,7 @@ if desired. The response body and headers of the last Interceptor is used for resource binding/templating. + ```YAML --- apiVersion: tekton.dev/v1alpha1 @@ -230,7 +231,6 @@ spec: name: pipeline-template ``` - ### GitHub Interceptors GitHub Interceptors contain logic to validate and filter webhooks that come from @@ -252,6 +252,7 @@ The body/header of the incoming request will be preserved in this Interceptor's response. + ```YAML --- apiVersion: tekton.dev/v1alpha1 @@ -275,7 +276,6 @@ spec: name: pipeline-template ``` - ### GitLab Interceptors GitLab Interceptors contain logic to validate and filter requests that come from @@ -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'`. @@ -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. + ```YAML apiVersion: tekton.dev/v1alpha1 kind: EventListener @@ -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. + ```YAML apiVersion: tekton.dev/v1alpha1 kind: EventListener @@ -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. + ```YAML apiVersion: tekton.dev/v1alpha1 kind: EventListener @@ -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. + ```YAML apiVersion: tekton.dev/v1alpha1 kind: EventListener @@ -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" } } } @@ -477,8 +482,8 @@ The output body would look like this: "ref": "refs/heads/master", "pull_request": { "head": { - "sha": "6113728f27ae82c7b1a177c8d03f9e96e0adf246", - }, + "sha": "6113728f27ae82c7b1a177c8d03f9e96e0adf246" + } }, "extensions": { "truncated_sha": "6113728", @@ -486,8 +491,9 @@ The output body would look like this: } } ``` -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: @@ -495,6 +501,7 @@ For example, this expression: - 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 @@ -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. + ```YAML apiVersion: tekton.dev/v1alpha1 kind: TriggerBinding