You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: test/gator/test/test.bats
+4Lines changed: 4 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -85,6 +85,10 @@ match_yaml_msg () {
85
85
! bin/gator test --filename="$BATS_TEST_DIRNAME/fixtures/manifests/with-policies/with-violations.yaml"
86
86
}
87
87
88
+
@test "manifest with rego v1 template and violations included as flag returns 1 exit status" {
89
+
! bin/gator test --filename="$BATS_TEST_DIRNAME/fixtures/manifests/with-policies/with-violations-rego-v1.yaml"
90
+
}
91
+
88
92
@test "multiple files passed in flags is supported" {
89
93
run bin/gator test --filename="$BATS_TEST_DIRNAME/fixtures/manifests/no-policies/with-violations.yaml" --filename="$BATS_TEST_DIRNAME/fixtures/policies/default" -oyaml
Copy file name to clipboardExpand all lines: website/docs/constrainttemplates.md
+69Lines changed: 69 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -158,3 +158,72 @@ k8srequiredlabels.constraints.gatekeeper.sh/ns-must-have-gk created
158
158
$ kubectl create ns foobar
159
159
Error from server ([ns-must-have-gk] you must provide labels: {"gatekeeper"}): admission webhook "validation.gatekeeper.sh" denied the request: [ns-must-have-gk] you must provide labels: {"gatekeeper"}
160
160
```
161
+
162
+
## Enable OPA Rego v1 syntax in ConstraintTemplates
163
+
164
+
Gatekeeper 3.19 ships with ability to use OPA Rego v1 as policy language in ConstraintTemplates. Using Rego v1 syntax is opt-in, by default only Rego v0 is allowed. You can use below spec to enable Rego v1 syntax:
165
+
166
+
```yaml
167
+
...
168
+
targets:
169
+
- target: admission.k8s.gatekeeper.sh
170
+
code:
171
+
- engine: Rego
172
+
source:
173
+
version: "v1"
174
+
rego: |
175
+
<v1-rego-code>
176
+
...
177
+
```
178
+
179
+
:::note
180
+
Rego v1 syntax can only be used under `targets[_].code[_].[engine: Rego].source` with `version: "v1"`. No need to add `import rego.v1` to use rego v1 syntax.
181
+
:::
182
+
183
+
Here is a sample ConstraintTemplate using Rego v1 syntax:
Copy file name to clipboardExpand all lines: website/versioned_docs/version-v3.19.x/constrainttemplates.md
+69Lines changed: 69 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -158,3 +158,72 @@ k8srequiredlabels.constraints.gatekeeper.sh/ns-must-have-gk created
158
158
$ kubectl create ns foobar
159
159
Error from server ([ns-must-have-gk] you must provide labels: {"gatekeeper"}): admission webhook "validation.gatekeeper.sh" denied the request: [ns-must-have-gk] you must provide labels: {"gatekeeper"}
160
160
```
161
+
162
+
## Enable OPA Rego v1 syntax in ConstraintTemplates
163
+
164
+
Gatekeeper 3.19 ships with ability to use OPA Rego v1 as policy language in ConstraintTemplates. Using Rego v1 syntax is opt-in, by default only Rego v0 is allowed. You can use below spec to enable Rego v1 syntax:
165
+
166
+
```yaml
167
+
...
168
+
targets:
169
+
- target: admission.k8s.gatekeeper.sh
170
+
code:
171
+
- engine: Rego
172
+
source:
173
+
version: "v1"
174
+
rego: |
175
+
<v1-rego-code>
176
+
...
177
+
```
178
+
179
+
:::note
180
+
Rego v1 syntax can only be used under `targets[_].code[_].[engine: Rego].source` with `version: "v1"`. No need to add `import rego.v1` to use rego v1 syntax.
181
+
:::
182
+
183
+
Here is a sample ConstraintTemplate using Rego v1 syntax:
0 commit comments