Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/itaysk/prego

prego - pipe into rego
https://github.com/itaysk/prego

Last synced: 26 days ago
JSON representation

prego - pipe into rego

Awesome Lists containing this project

README

        

Prego - Pipe into Rego

Prego is a stream processing cli tool that takes JSON from stdin, and processes it using [Rego](https://www.openpolicyagent.org/docs/latest/policy-language/) (the [Open Policy Agent](https://www.openpolicyagent.org/) language). It is inspired by [AWK](https://en.wikipedia.org/wiki/AWK) and can be thought of an AWK/Rego hybrid.

## Getting Prego
Currently you have to build from source. Clone the repo and run `make build`.

## Getting Started

Let's try Prego with the included example in [test/example.rego](test/example.rego). This is an example that:
1. Prints the time when it started and finished.
2. Looks in the input json for `.foo` elements which have a value of `bar`.
1. Those items will be printed out.
3. Looks in the input json for `.hello` elements.
1. For those items it will print the value of `.hello` in uppercase letters.
4. Every other items that doesn't match those conditions will be ignored (not printed).

Run `prego -f test/example.rego`, and type input documents (as JSON), or use the example data: `prego -f test/example.rego