Datasets:
AutoOntologyBench / source_data /pinned /gatekeeper-library /commit-a8d4799d8daf /src /general /requiredannotations /src.rego
Download source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/src/general/requiredannotations/src.rego from Vinyeh/AutoOntologyBench: direct link, hf CLI and curl.
- Browser
- Download file 740 Bytes
-
https://huggingface.co/datasets/Vinyeh/AutoOntologyBench/resolve/main/source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/src/general/requiredannotations/src.rego
- Command line
-
hf download hf://datasets/Vinyeh/AutoOntologyBench/source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/src/general/requiredannotations/src.rego
-
curl -L -o src.rego https://huggingface.co/datasets/Vinyeh/AutoOntologyBench/resolve/main/source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/src/general/requiredannotations/src.rego
740 Bytes
| package k8srequiredannotations | |
| violation[{"msg": msg, "details": {"missing_annotations": missing}}] { | |
| provided := {annotation | input.review.object.metadata.annotations[annotation]} | |
| required := {annotation | annotation := input.parameters.annotations[_].key} | |
| missing := required - provided | |
| count(missing) > 0 | |
| msg := sprintf("you must provide annotation(s): %v", [missing]) | |
| } | |
| violation[{"msg": msg}] { | |
| value := input.review.object.metadata.annotations[key] | |
| expected := input.parameters.annotations[_] | |
| expected.key == key | |
| expected.allowedRegex != "" | |
| not regex.match(expected.allowedRegex, value) | |
| msg := sprintf("Annotation <%v: %v> does not satisfy allowed regex: %v", [key, value, expected.allowedRegex]) | |
| } | |