feat: init commit

This commit is contained in:
2023-01-17 22:45:23 +08:00
commit 94130c107c
72 changed files with 7568 additions and 0 deletions

View File

@@ -0,0 +1,12 @@
# Open Policy Agent utility
This folder contains the entry point for Open Policy Agent policies.
Since Open Policy Agent policies have to produce an `AdmissionReview`
object, this utility library contains the Rego entry point that
generates such `AdmissionReview`, based on whether the `deny` query
inside the package `kubernetes.admission` (defined by the policy
itself) is evaluated to `true`.
If `deny` evaluates to true, the produced `AdmissionReview` will
reject the request. Otherwise, it will be accepted.

View File

@@ -0,0 +1,23 @@
package policy
import data.kubernetes.admission
main = {
"apiVersion": "admission.k8s.io/v1",
"kind": "AdmissionReview",
"response": response,
}
response = {
"uid": input.request.uid,
"allowed": false,
"status": {"message": reason},
} {
reason = concat(", ", admission.deny)
reason != ""
} else = {
"uid": input.request.uid,
"allowed": true,
} {
true
}