Wrapper rules on the opa cli.
Those dependencies must be installed in the WORKSPACE
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "rules_opa",
sha256 = "<SHA256>",
strip_prefix = "rules_opa-<VERSION>",
url = "https://github.com/ticketmaster/rules_opa/archive/refs/tags/<VERSION>.tar.gz",
)
load("@rules_opa//opa:deps.bzl", "opa_register_toolchains", "opa_rules_dependencies")
opa_rules_dependencies()
opa_register_toolchains()See examples for more information
load("@rules_opa//opa:defs.bzl", "opa_check", "opa_eval_binary", "opa_library", "opa_test")
opa_library(
name = "simple",
srcs = ["main.rego"],
data = ["data.json"],
strip_prefix = package_name(),
)
opa_test(
name = "simple_test",
size = "small",
srcs = ["main_test.rego"],
bundle = ":simple",
)To upgrade the opa version, run the following command
bazel run -- //tools:opa_upgrade --version <version>