github open-policy-agent/opa v1.2.0

21 hours ago

This release contains a mix of features, performance improvements, and bugfixes.

Parameterized Rego Tests (#2176)

Rego tests now support parameterization, allowing a single test rule to include multiple, hierarchical, named test cases.
This feature is useful for data-driven testing, where a single test rule can be used for multiple test cases with different inputs and expected outputs.

package example_test

test_concat[note] if {
	some note, tc in {
		"empty + empty": {
			"a": [],
			"b": [],
			"exp": [],
		},
		"empty + filled": {
			"a": [],
			"b": [1, 2],
			"exp": [1, 2],
		},
		"filled + filled": {
			"a": [1, 2],
			"b": [3, 4],
			"exp": [1, 2, 3], # Faulty expectation, this test case will fail
		},
	}

	act := array.concat(tc.a, tc.b)
	act == tc.exp
}
$ opa test example_test.rego
example_test.rego:
data.example_test.test_concat: FAIL (263.375µs)
  empty + empty: PASS
  empty + filled: PASS
  filled + filled: FAIL
--------------------------------------------------------------------------------
FAIL: 1/1

See the documentation for more information.

Authored by @johanfylling, reported by @anderseknert

Performance Improvements

Topdown and Rego

Runtime, Tooling, SDK

Docs, Website, Ecosystem

Miscellaneous

  • build+test: Add make test-short task (#7364) (authored by @anderseknert)
  • build: Add gocritic linter (#7377) authored by @anderseknert
  • build: Add nilness linter from govet (#7335) authored by @anderseknert
  • build: Add perfsprint linter (#7334) authored by @anderseknert
  • ci: Tagging release binaries with build version (#7395, #7397, #7400) authored by @johanfylling
  • test: fix race in TestIntraQueryCache_ClientError and TestInterQueryCache_ClientError (#7280) authored by @Juneezee
  • misc: Use Go 1.22+ int ranges (#7328) authored by @anderseknert
  • Dependency updates; notably:
    • build: bump go from 1.23.5 to 1.24.0
    • build(deps): bump github.com/agnivade/levenshtein from 1.2.0 to 1.2.1
    • build(deps): bump github.com/containerd/containerd from 1.7.25 to 1.7.26
    • build(deps): bump github.com/google/go-cmp from 0.6.0 to 0.7.0
    • build(deps): bump github.com/prometheus/client_golang
    • build(deps): bump github.com/spf13/cobra from 1.8.1 to 1.9.1
    • build(deps): bump github.com/spf13/pflag from 1.0.5 to 1.0.6
    • build(deps): bump golang.org/x/net from 0.34.0 to 0.35.0
    • build(deps): bump golang.org/x/time from 0.9.0 to 0.10.0
    • build(deps): bump ossf/scorecard-action from 2.4.0 to 2.4.1
    • Bump golangci-lint from v1.60.1 to 1.64.5

Don't miss a new opa release

NewReleases is sending notifications on new releases.