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])}." } }