Commit Graph

11 Commits

Author SHA1 Message Date
Anders Eknert afb30d3f9d Add gocritic linter, fix a bunch of stuff (#7377)
Brace yourselves! For there are many touched files here. No changes
in semantics however.

Spent a long time trying out the various optional rules gocritic
provides, and settled for a few of them. There are more I really
like, but that would take many hours to address across the codebase.

Perhaps others find gocritic too pedantic? If so, we can merge the
fixes without enabling the rule.

Signed-off-by: Anders Eknert <anders@styra.com>
2025-02-24 16:28:41 +01:00
Anders Eknert b942136a4a Use Go 1.22+ int ranges (#7328)
With "some" help from `golangci-lint run --fix ./...`

Signed-off-by: Anders Eknert <anders@styra.com>
2025-01-30 09:57:27 +01:00
Johan Fylling a179a24c48 v1 API
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>
2024-12-12 15:27:34 +01:00
Johan Fylling 7bb6dbe36b Preparing for v1 API
Moving (most) source to v1 root package to prepare for v0/v1 API separation.

Signed-off-by: Johan Fylling <johan.dev@fylling.se>
2024-12-12 15:09:03 +01:00
Johan Fylling 5521453d87 cmd: Adding --v0-compatible flag (#7065)
To make OPA behave as v0.x post v1.0 release.
If used simultaneously with `--v1-compatible` flag, the `--v0-compatible` flag takes precedence.

Also, future-proofing `cmd` package tests for 1.0.

Signed-off-by: Johan Fylling <johan.dev@fylling.se>
2024-09-26 00:45:51 +02:00
Johan Fylling b36151d992 Adding --v1-compatible flag to all previously unsupported command line commands (#6521)
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>
2024-01-24 15:42:32 +01:00
Charlie Egan cd0bf5b4d2 Add option to marshal location text (#6234) 2023-09-21 09:40:07 +01:00
Ronnie-personal 38733ed746 ast: Add location to single entry rule head ref (#6212)
Fixes: #6199
Signed-off-by: Ronnie Personal <76408835+Ronnie-personal@users.noreply.github.com>
2023-09-18 11:45:51 +02:00
Gianluca Oldani 1e38591597 parse: include rule head location when requested
Prior to this commit, when the AST information
were serialized to JSON, rules expressed as

discussed in #5790 included only the location
of their value and not the one of the rule
ref var itself. Now the AST serialized to
JSON includes this information.

Fixes: #5790
Signed-off-by: Gianluca Oldani <oldanigianluca@gmail.com>
2023-04-18 16:55:55 -07:00
Charlie Egan fbfa705063 [ast/opa parse] Support marshalling of all ast location data (#5576)
Signed-off-by: Charlie Egan <charlie@styra.com>
2023-03-09 09:49:30 +00:00
Patrick East 4f323e0597 cmd: Add very basic parse cmd coverage
There was an issue a little while back where we had a panic in the
command but there is zero test coverage exercising it... so we never
noticed.

This at least will get us some bare-bones test coverage to ensure
it isn't crashing on some basic use-cases.

Signed-off-by: Patrick East <east.patrick@gmail.com>
2020-03-23 06:06:39 -07:00