Skip to content

Commit

Permalink
Fixes more cel interceptor usage syntax in cel_expressions.md
Browse files Browse the repository at this point in the history
  • Loading branch information
danielfbm authored and tekton-robot committed Jul 24, 2024
1 parent f151b59 commit fdda054
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions docs/cel_expressions.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ interceptors:
name: cel
params:
- name: overlays
values:
value:
- key: count_plus_1
expression: "body.count + 1.0"
- key: count_plus_2
Expand Down Expand Up @@ -91,8 +91,8 @@ interceptors:
- ref:
name: cel
params:
- name: overlays:
values:
- name: overlays
value:
- key: bad_measure_times_3
expression: "body.measure * 3"
```
Expand Down Expand Up @@ -133,15 +133,17 @@ You can use this in filters in the following ways:

You can also parse additional data from each of the labels:
```yaml
overlays:
- key: suffixes
expression: "body.labels.map(x, x.name.substring(x.name.lastIndexOf('-')+1))"
- name: overlays
value:
- key: suffixes
expression: "body.labels.map(x, x.name.substring(x.name.lastIndexOf('-')+1))"
```
This yields an array of `["a", "b"]` in the `suffixes` extension key.
```yaml
overlays:
- key: filtered
expression: "body.labels.filter(x, x.name.endsWith('-b'))"
- name: overlays
value:
- key: filtered
expression: "body.labels.filter(x, x.name.endsWith('-b'))"
```
This would add an extensions key `filtered` with only one of the labels.
```yaml
Expand Down Expand Up @@ -184,8 +186,11 @@ you will need to explicitly convert it to a CEL string.

```yaml
interceptors:
- cel:
overlays:
- ref:
name: "cel"
params:
- name: "overlays"
value:
- key: base64_decoded
expression: "string(base64.decode(body.b64Value))"
```
Expand Down

0 comments on commit fdda054

Please sign in to comment.