OPA/Rego deployment gateway policies: 5 rules (valid-environment, require-approvals, no-self-approval, block-weekends, freeze-window), a deploy-gate combining them, JSON schemas, scenario-driven tests, Gitea Actions CI (verify + publish to generic registry), changesets versioning, Makefile and scripts.
3.9 KiB
3.9 KiB
Tech Stack
Overview
| Layer | Technology | Version | Purpose |
|---|---|---|---|
| Policy language | Rego | OPA 1.x (rego.v1) |
Authoring deployment-gateway policy rules and gates |
| Policy engine | OPA | v1.20.2 (pinned) |
Evaluating, testing, type-checking and bundling the policies |
| Policy linter | regal | v0.42.0 |
Static linting of Rego best practices (optional in CI) |
| Bundles | OPA bundle format | — | Distributable .tar.gz bundles (rule modules at data.rules.*) |
| Schemas | JSON Schema (draft 2020-12) | — | Static validation of input and data via opa check --schema |
| Versioning | Changesets | @changesets/cli@3.0.3 |
Tracking per-policy version bumps across npm workspaces |
| Changelog formatting | oxfmt | ^0.68.0 |
Formatting generated changelogs/changesets via format: "oxfmt" |
| Package management | npm workspaces | npm 11 / Node 24 | Monorepo layout (policies/rules/*, policies/gates/*) |
| CI/CD | Gitea Actions | Gitea 1.27.0 | Verify, test, build and publish on main |
| Package registry | Gitea generic registry | — | Storing published rule/gate bundles |
| Build tooling | GNU make + bash | — | Makefile targets wrapping the scripts |
| Hosting | Gitea self-hosted | 1.27.0 |
Source control, CI runners, package registry (gitea.devegamoreno.com) |
Justification
- OPA + Rego: standard, policy-as-code engine for authorization/gating; bundles are the portable distribution unit; binary CLI avoids container runtime requirements.
- Pinned OPA
v1.20.2: reproducible engine version locally and in CI viascripts/install-opa.sh(no Docker), so tests andopa buildsee identical behaviour everywhere. rego.v1: canonical OPA 1.x syntax (import ofrego.v1), future-proof and unambiguous.- Per-rule JSON Schemas:
opa check --strict --schemacatches input/data type mistakes at authoring time instead of runtime. - Separate evaluation / small rules: each rule is an independent package+bundle with a small, testable contract; consumers combine the results at runtime, enabling reuse across gates.
- Changesets over npm workspaces: each rule/gate is an npm package solely for versioning;
changesets links repository-level changes to published registry versions.
oxfmtis used only to format changelog markdown (there is noprettier-plugin-regoon npm), while Rego formatting is enforced byopa fmtin CI. - Gitea generic registry: stores arbitrary files (
.tar.gzbundles) under/api/packages/{owner}/generic/{package}/{version}/{file}without adding an external registry dependency. - npm workspaces (over pnpm/yarn): zero extra tooling; changesets v3 requires Node ≥ 22.11 and npm ≥ 10.9, both met.
Tools not used (and why)
- Docker/containers: excluded by design; OPA ships a static binary, so containers add unnecessary runtime complexity for tests, checks and bundle builds.
- prettier-plugin-rego: does not exist on npm (verified 404); Rego formatting is
instead owned by
opa fmt. - pnpm/yarn: changesets supports them, but npm workspaces suffice since these packages are private versioning shims, not published JS packages.
Integration points
- Gitea Actions reads
secrets.GITEA_TOKEN(scopewrite:package) andGITEA_OWNER/GITEA_URL; publish job runs only onmain. scripts/publish.shuploads viacurlto the generic registry; package names are prefixedrule-*andgate-*.- Consumer contract: bundles scope roots to
rulesso operators can supplydata.deploygate.*configuration separately and still have static schema checks apply.
Environment (local dev machine)
- macOS (darwin/arm64), zsh
- Node.js
v24.18.0, npm11.16.0 - git
2.50.1, GNU make tools/opa(OPAv1.20.2binary committed to the repo working tree via install script, not git)- regal
v0.42.0optional onPATH