Skip to content

Commit

Permalink
feat: add cel test (#2049) (#2050)
Browse files Browse the repository at this point in the history
Signed-off-by: Charles-Edouard Brétéché <[email protected]>
Co-authored-by: Charles-Edouard Brétéché <[email protected]>
  • Loading branch information
gcp-cherry-pick-bot[bot] and eddycharly authored Sep 30, 2024
1 parent 5229eac commit c35fbd4
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 1 deletion.
2 changes: 1 addition & 1 deletion testdata/e2e/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ spec:
template:
metadata:
annotations:
from-config-file: ("hello")
from-config-file: (string("hello"))
1 change: 1 addition & 0 deletions testdata/e2e/examples/CATALOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- [basic](basic/README.md)
- [bindings](bindings/README.md)
- [catch](catch/README.md)
- [cel](cel/README.md)
- [command-output](command-output/README.md)
- [delete](delete/README.md)
- [delete](delete/README.md)
Expand Down
51 changes: 51 additions & 0 deletions testdata/e2e/examples/cel/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Test: `cel`

*No description*

## Bindings

| # | Name | Value |
|:-:|---|---|
| 1 | `a` | 1 |

## Steps

| # | Name | Bindings | Try | Catch | Finally | Cleanup |
|:-:|---|:-:|:-:|:-:|:-:|
| 1 | [step-1](#step-step-1) | 1 | 1 | 0 | 0 | 0 |
| 2 | [step-2](#step-step-2) | 1 | 1 | 0 | 0 | 0 |

### Step: `step-1`

*No description*

#### Bindings

| # | Name | Value |
|:-:|---|---|
| 1 | `b` | 2 |

#### Try

| # | Operation | Bindings | Outputs | Description |
|:-:|---|:-:|:-:|---|
| 1 | `apply` | 1 | 0 | *No description* |

### Step: `step-2`

*No description*

#### Bindings

| # | Name | Value |
|:-:|---|---|
| 1 | `b` | 2 |

#### Try

| # | Operation | Bindings | Outputs | Description |
|:-:|---|:-:|:-:|---|
| 1 | `assert` | 1 | 0 | *No description* |

---

47 changes: 47 additions & 0 deletions testdata/e2e/examples/cel/chainsaw-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# yaml-language-server: $schema=../../../../.schemas/json/test-chainsaw-v1alpha1.json
apiVersion: chainsaw.kyverno.io/v1alpha1
kind: Test
metadata:
name: cel
spec:
bindings:
- name: a
value: 1
steps:
- bindings:
- name: b
value: 2
try:
- compiler: cel
apply:
template: true
bindings:
- name: c
value: (string(bindings.resolve("a") + bindings.resolve("b")))
resource:
apiVersion: v1
kind: ConfigMap
metadata:
name: quick-start
data:
cel: (cel; bindings.resolve("c"))
jp: (jp; $c)
default: (bindings.resolve("c"))
- bindings:
- name: b
value: 2
try:
- assert:
bindings:
- name: c
compiler: cel
value: (string(bindings.resolve("a") + bindings.resolve("b")))
resource:
apiVersion: v1
kind: ConfigMap
metadata:
name: quick-start
data:
cel: (cel; bindings.resolve("c"))
jp: (jp; $c)
default: ($c)

0 comments on commit c35fbd4

Please sign in to comment.