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>
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>
Previously the type checker would not sort errors before returning
them. As a result, the ordering of errors would depend on the order of
rules passed to the type checker (which is non-deterministic due to Go
map iteration order.)
These changes update the type checker to sort errors by location
before before returning them. This way the errors reported by opa test
and opa check and everything else are consistent across runs.
Fixes#1620
Signed-off-by: Torin Sandall <torinsandall@gmail.com>
In b23cb4e the compiler was changed to allow queries to refer to the
input document without the input document being defined. Those changes
did not remove all of the code associated with input errors.
These changes remove the remaining (dead) code associated with input
errors and also update the server to allow Data API POST requests that
do not specify an input document.
- Refactor error codes to use strings instead of ints.
- Simplify error messages throughout.
- Ensure location set on all expressions. There were a couple locations
in the parser/compiler where locations were not being set.
- Fallback to rule location in topdown in case location not set. This
ensures that users get useful locations for API requests with paths
that refer to virtual docs exactly.
Also add Find function to ast.Value. Useful for extracting values
dynamically. Eventually can support JSON pointers.
Fixes#237
These changes update OPA to analyze queries to determine if an input
document is required. In the future, more sophisticated checks could be
performed (e.g., JSON schema validation).
If an input document is required but not provided, OPA will return HTTP
400 (per the documentation). This was broken in #197.
Fixes#227
Previously, errors returned by the parser and compiler would encode the
location information in the error string. Now, the location information is
structured and can be readily used by consumers.
Before, callers would either flatten errors to a string or pick the first
error reported by the compiler. This was a bad approach and lead to an issue
for users running OPA from the command line, for example:
$ opa run test.rego
If test.rego failed to compile, the run command would only print the first
error...
This change lets callers treat all compiler errors as a single error and
factors the flattening into the Error() implementation of the new ast.Errors
type.