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.
22 lines
549 B
Rego
22 lines
549 B
Rego
# METADATA
|
|
# schemas:
|
|
# - input: schema["input"]
|
|
# - data: schema["data"]
|
|
|
|
package rules.block_weekends
|
|
|
|
import rego.v1
|
|
|
|
default allow := false
|
|
|
|
allow if {
|
|
count(violations) == 0
|
|
}
|
|
|
|
violations contains {"code": "weekend_deploy", "message": sprintf("deployments blocked on %s for environment %q", [weekday, input.deployment.environment])} if {
|
|
input.deployment
|
|
weekday := time.weekday(time.parse_rfc3339_ns(input.deployment.created_at))
|
|
weekday in {"Saturday", "Sunday"}
|
|
data.deploygate.config[input.deployment.environment].block_weekends
|
|
}
|