This repository has been archived on 2026-11-21. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
terraform-git/modules/github_org/variables.tf
T
unkin-agent a99c8f04fd
ci/woodpecker/pr/pre-commit Pipeline was successful
ci/woodpecker/pr/plan Pipeline was successful
archive github repos on destroy, reject unknown rulesets
2026-11-10 00:05:34 +11:00

80 lines
3.0 KiB
Terraform

variable "owner" {
description = "GitHub organisation that owns every resource"
type = string
}
variable "team" {
description = "Map of teams to create, keyed by name"
type = map(object({
name = string
description = optional(string, "")
privacy = optional(string, "closed")
maintainers = optional(list(string), [])
members = optional(list(string), [])
}))
default = {}
}
variable "ruleset" {
description = "Map of reusable repository ruleset definitions, keyed by name"
type = map(object({
name = string
target = optional(string, "branch")
enforcement = optional(string, "active")
conditions = optional(object({
ref_name = object({
include = list(string)
exclude = optional(list(string), [])
})
}))
rules = object({
deletion = optional(bool, false)
non_fast_forward = optional(bool, false)
pull_request = optional(object({
required_approving_review_count = optional(number, 0)
dismiss_stale_reviews_on_push = optional(bool, false)
require_code_owner_review = optional(bool, false)
require_last_push_approval = optional(bool, false)
required_review_thread_resolution = optional(bool, false)
}))
required_status_checks = optional(object({
contexts = list(string)
strict = optional(bool, false)
}))
})
}))
default = {}
}
variable "repository" {
description = "Map of repositories to create, keyed by name"
type = map(object({
name = string
description = optional(string, "")
private = optional(bool, true)
rulesets = optional(list(string), [])
maintainers = optional(list(string), [])
codeowners = optional(list(string), [])
default_branch = optional(string, "main")
has_issues = optional(bool, true)
has_wiki = optional(bool, false)
has_projects = optional(bool, false)
allow_squash_merge = optional(bool, true)
allow_merge_commit = optional(bool, false)
allow_rebase_merge = optional(bool, false)
delete_branch_on_merge = optional(bool, true)
auto_init = optional(bool, true)
}))
default = {}
validation {
condition = alltrue([for repo in var.repository : !(repo.private && length(repo.rulesets) > 0)])
error_message = "Rulesets are not enforced on private repositories on the GitHub free plan: ${join(", ", [for name, repo in var.repository : name if repo.private && length(repo.rulesets) > 0])}."
}
validation {
condition = alltrue(flatten([for repo in var.repository : [for rs in repo.rulesets : contains(keys(var.ruleset), rs)]]))
error_message = "Unknown rulesets referenced: ${join(", ", distinct(flatten([for name, repo in var.repository : [for rs in repo.rulesets : "${name}/${rs}" if !contains(keys(var.ruleset), rs)]])))}."
}
}