https://github.com/ticketmaster/rules_opa
Bazel rules for OPA
https://github.com/ticketmaster/rules_opa
Last synced: 5 months ago
JSON representation
Bazel rules for OPA
- Host: GitHub
- URL: https://github.com/ticketmaster/rules_opa
- Owner: ticketmaster
- License: mit
- Created: 2023-07-04T17:59:57.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2025-12-16T18:31:53.000Z (6 months ago)
- Last Synced: 2025-12-19T02:06:28.112Z (6 months ago)
- Language: Starlark
- Size: 145 KB
- Stars: 10
- Watchers: 7
- Forks: 2
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# [OPA](https://www.openpolicyagent.org/) rules for [Bazel](https://bazel.build/)
## Contents
* [Overview](#overview)
* [Setup](#setup)
* [Usage](#usage)
## Overview
Wrapper rules on the opa cli.
## Setup
Those dependencies must be installed in the WORKSPACE
* [Skylib](https://github.com/bazelbuild/bazel-skylib)
* [Python Rules](https://github.com/bazelbuild/rules_python)
bzlmod usage (until it's available in the registry)
```starlark
bazel_dep(name = "rules_opa", version = )
git_override(
module_name = "rules_opa",
commit = ,
remote = "https://github.com/ticketmaster/rules_opa",
)
```
Legacy workspace
```starlark
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "rules_opa",
sha256 = "",
strip_prefix = "rules_opa-",
url = "https://github.com/ticketmaster/rules_opa/archive/refs/tags/.tar.gz",
)
load("@rules_opa//opa:deps.bzl", "opa_register_toolchains", "opa_rules_dependencies")
opa_rules_dependencies()
opa_register_toolchains()
```
## Usage
See [examples](examples) for more information
```starlark
load("@rules_opa//opa:defs.bzl", "opa_check", "opa_eval_binary", "opa_library", "opa_test")
opa_library(
name = "simple",
srcs = ["main.rego", "data.json"],
strip_prefix = package_name(),
)
opa_test(
name = "simple_test",
size = "small",
srcs = ["main_test.rego"],
bundle = ":simple",
)
```
## Upgrade
To upgrade the opa version, run the following command
```shell
bazel run -- //tools:opa_upgrade --version
```