Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/aavarghese/opa-schema-examples
Example files for supporting schema type checking for OPA
https://github.com/aavarghese/opa-schema-examples
Last synced: about 2 months ago
JSON representation
Example files for supporting schema type checking for OPA
- Host: GitHub
- URL: https://github.com/aavarghese/opa-schema-examples
- Owner: aavarghese
- License: apache-2.0
- Created: 2021-01-08T16:52:58.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2021-08-01T13:04:55.000Z (over 3 years ago)
- Last Synced: 2024-07-25T12:52:34.021Z (6 months ago)
- Language: Open Policy Agent
- Size: 69.5 MB
- Stars: 9
- Watchers: 2
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-opa - OPA Schema Examples - Examples of extending the OPA type checker with JSON [schemas](https://www.openpolicyagent.org/docs/latest/schemas/) (Tools and Utilities / Testing Blogs and Articles)
README
# opa-schema-examples
A new feature allows Rego's type system to take into account the schemas for input documents. This adds precision to type checking and helps prevent errors when writing Rego code. It helps users by rejecting erroneous code statically and improving developer productivity. It uses JSON Schema as the format for providing schemas.
This repo contains example files to illustrate the new feature.
## How to run
We added a new query argument to `opa eval` to support uploading of a single schema for the input document in JSON Schema format.
```
-s, --schema string set schema file path
```## Examples
```
opa eval --format pretty data.example.public_server -i opa-example/input.json -d opa-example/example.rego -s opa-example/input-schema.json
``````
opa eval --format pretty data.kubernetes.admission.deny -i kubernetes/admission-review.json -d kubernetes/pod.rego -s kubernetes/admission-schema.json
``````
opa eval --format pretty data.terraform.analysis.authz -i terraform/tf-plan.json -d terraform/terraform.rego -s terraform/tf-schema.json
```