Add bypass_actors support to GitHub rulesets
This commit is contained in:
@@ -23,6 +23,12 @@ variable "ruleset" {
|
||||
mandatory = optional(bool, false)
|
||||
target = optional(string, "branch")
|
||||
enforcement = optional(string, "active")
|
||||
bypass_actors = optional(list(object({
|
||||
actor_type = string
|
||||
actor_id = optional(number)
|
||||
team = optional(string)
|
||||
bypass_mode = optional(string, "always")
|
||||
})), [])
|
||||
conditions = optional(object({
|
||||
ref_name = object({
|
||||
include = list(string)
|
||||
@@ -53,6 +59,16 @@ variable "ruleset" {
|
||||
error_message = "pull_request and required_status_checks are branch-only rules, not allowed on tag rulesets: ${join(", ", [for k, rs in var.ruleset : k if rs.target != "branch" && (rs.rules.pull_request != null || rs.rules.required_status_checks != null)])}."
|
||||
}
|
||||
|
||||
validation {
|
||||
condition = alltrue(flatten([for rs in var.ruleset : [for a in rs.bypass_actors : (a.actor_type == "Team") == (a.team != null)]]))
|
||||
error_message = "bypass_actors team must be set exactly when actor_type is Team: ${join(", ", flatten([for k, rs in var.ruleset : [for a in rs.bypass_actors : "${k}/${a.actor_type}" if(a.actor_type == "Team") != (a.team != null)]]))}."
|
||||
}
|
||||
|
||||
validation {
|
||||
condition = alltrue(flatten([for rs in var.ruleset : [for a in rs.bypass_actors : contains(keys(var.team), a.team) if a.team != null]]))
|
||||
error_message = "Unknown bypass teams referenced: ${join(", ", distinct(flatten([for name, rs in var.ruleset : [for a in rs.bypass_actors : "${name}/${a.team}" if a.team != null && !contains(keys(var.team), coalesce(a.team, "-"))]])))}."
|
||||
}
|
||||
|
||||
validation {
|
||||
condition = alltrue([for rs in var.ruleset : rs.rules.required_status_checks == null || length(rs.rules.required_status_checks.contexts) > 0])
|
||||
error_message = "required_status_checks.contexts must not be empty: ${join(", ", [for k, rs in var.ruleset : k if rs.rules.required_status_checks != null && length(rs.rules.required_status_checks.contexts) == 0])}."
|
||||
|
||||
Reference in New Issue
Block a user