6 Commits

Author SHA1 Message Date
Anders Eknert db035b09fc Add support for Go 1.27 & jsonv2 (#8947)
Makes OPA build and pass its tests on Go 1.27, while keeping Go 1.25 and
1.26 working. JSON output is unchanged on every supported version.

Go 1.27 json package honours `encoding.TextAppender`. Many v1 ast types
implement AppendText to build their Rego string cheaply, so on 1.27 they
would have marshalled as Rego text. Files built only with 1.27 now
implement MarshalJSONTo.

Library users should keep using `json.Marshal` etc. The MarshalJSONTo
methods are implementation details, are absent from 1.25 and 1.26
builds, and may change.

---------

Signed-off-by: Anders Eknert <anders.eknert@apple.com>
Signed-off-by: Charlie Egan <charlie_egan@apple.com>
Co-authored-by: Charlie Egan <charlie_egan@apple.com>
2026-07-30 17:41:28 +01:00
Stephan Renatus 7750005131 benchmarks: smaller tweaks
The crypto benchmark was allocating Bytes() in the b.Loop(), and there's
no need for that.

The semver benchmark had some duplicate fixtures.

Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
2026-06-10 11:01:21 +02:00
Anders Eknert 30d3346fb4 New custom SemVer implementation (#8010)
This was something I originally intended to use in another project,
but since this turned out to be a better implementation (subject of
course to review!) in terms of both performance and simplicity, I
figured we might as well use it here too. Some changes include:

- `MustParse` to parse known valid versions
- Allocates nothing in any operations other than 1 alloc in `String()`
- Ignores empty `PreRelease` and `Metadata` fields in serialization
- `encoding.TextAppender` implementation to serialize without allocating
- A whole bunch of benchmarks

Signed-off-by: Anders Eknert <anders@eknert.com>
2025-11-04 09:09:50 +01:00
Johan Fylling e6865c4c9f Prepare v1.10.0 release (#8002)
Signed-off-by: Johan Fylling <johan.dev@fylling.se>
2025-10-31 14:15:30 +01:00
Will Beason 3be1d08b87 Change check-lint to use golangci-lint (#3465)
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>
2021-05-19 07:52:02 +02:00
Charlie Egan 8d321f0856 Add semver.compare & is_valid built-ins
These built-ins will allow policies to more easily make comparisons on
semantic version strings.

I am doing this because I recently needed to write policy concerning
versions of installed software in Kubernetes environments.

I feel this is a better solution than implementing such a feature in
Rego: https://gist.github.com/charlieegan3/76dbec05c65164ac98dfec74b1381c5a

is_valid is to allow users to gate access to the compare function which
fails if the input is not a valid version string.

The semver functionality is vendored from the coreos package based on
the discussion here:
https://github.com/open-policy-agent/opa/pull/2538#pullrequestreview-448422711

Signed-off-by: Charlie Egan <charlieegan3@users.noreply.github.com>
2020-07-15 16:06:14 -07:00