All packages, except for `cmd` and `internal`, have been moved into a new `v1` root package.
Old packages are kept for backwards-compatibility reasons. All contained code is replaced with simple type aliases and proxy functions to `v1` implementations.
Old packages default to the Rego v0 syntax, new `v1` packages default to the Rego v1 syntax.
Signed-off-by: Johan Fylling <johan.dev@fylling.se>
In addition to those commands already supported:
* build
* check
* eval
* fmt
* test
support has been added to the following commands:
* `bench`
* `deps`
* `exec`
* `inspect`
* `parse`
* `run` (command `server` and `REPL`)
Fixes: #6520
Signed-off-by: Johan Fylling <johan.dev@fylling.se>
This will allow users of the SDK to see the version information of the
bundles used in decisions as well as the OPA SDK version.
Signed-off-by: Charlie Egan <charlieegan3@users.noreply.github.com>
This commit adds the `prealloc` linter to the list of linters for OPA, and fixes up the miscellaneous locations in the code that the linter found where we could easily preallocate slices.
Signed-off-by: Philip Conrad <philipaconrad@gmail.com>
The test server expects mock bundle files to be prefixed with
/bundles/ so return an error if they are not (otherwise the user has
to dig into the test server code to figure out why their test is not working.)
Signed-off-by: Torin Sandall <torinsandall@gmail.com>
golint is deprecated. The author of the code no longer supports the
codebase. golangci-lint is faster than golint, and is in use by other
opa repositories (e.g. Gatekeeper).
This commit changes tools.go to reference golangci (so it ends up in
vendor) and modifies check-lint to use golangci instead.
Breaking API Changes:
- plugins/rest/rest.go: Fix typo "AllowInsureTLS" -> "AllowInsecureTLS"
- storage/errors.go: Removed unused IndexingNotSupportedErr
Signed-off-by: Will Beason <willbeason@google.com>
This commit updates the test server so that callers can control when
the server becomes ready. This allows us to test the async option on
the SDK without worrying about race conditions. I.e., we can block
server readiness and assert that the SDK returns undefined until ready.
Signed-off-by: Torin Sandall <torinsandall@gmail.com>
This commit adds a new top-level package for integration with OPA. The
SDK defines a simple interface for OPA integrations that require the
management APIs. The APIs allow callers to instantiate an instance of
OPA by specifying the OPA configuration as a file or byte slice. The
SDK implements basic lifecycle management so that callers can control
whether startup blocks the calling thread (or not). Also, callers can
control the log level of debug and console logs emitted by the OPA. In
the future, other options could be exposed but for now we choose to
keep the API as simple as possible (as we will be aiming for
consistency across multiple languages eventually, we want to keep the
surface area small as possible.)
For policy queries, users can supply wallclock time, the decision
name, and the value of the input document. The SDK ensures the
wallclock time is consistent across time.now_ns() and the decision log
record (for replay purposes). The SDK incldues a dedicated
"sdk_decision_eval" metric that records the total decision latency for
monitoring purposes. The SDK ensures the input document is not
processed more than necessary (i.e., it parses into an AST value which
is reused for decision log masking.) Finally, the SDK includes a UUID
in the result which can be used for correlation with the decision log.
Co-authored-by: Torin Sandall <torinsandall@gmail.com>
Co-authored-by: Anders Eknert <anders@eknert.com>
Signed-off-by: Torin Sandall <torinsandall@gmail.com>
Signed-off-by: Anders Eknert <anders@eknert.com>