Skip to content

omnicate/rules_opa

 
 

Repository files navigation

OPA rules for Bazel

Contents

Overview

Wrapper rules on the opa cli.

Setup

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()

Usage

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",
)

Upgrade

To upgrade the opa version, run the following command

bazel run -- //tools:opa_upgrade --version <version>

About

Bazel rules for OPA

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Starlark 77.9%
  • Python 22.1%