generate github rulesets from repo flags, trim repo schema
This commit is contained in:
@@ -44,6 +44,11 @@ variable "ruleset" {
|
||||
})
|
||||
}))
|
||||
default = {}
|
||||
|
||||
validation {
|
||||
condition = length(setintersection(keys(var.ruleset), ["branch-protection", "required-checks"])) == 0
|
||||
error_message = "Ruleset names branch-protection and required-checks are reserved for generated rulesets."
|
||||
}
|
||||
}
|
||||
|
||||
variable "repository" {
|
||||
@@ -52,24 +57,35 @@ variable "repository" {
|
||||
name = string
|
||||
description = optional(string, "")
|
||||
private = optional(bool, true)
|
||||
rulesets = optional(list(string), [])
|
||||
default_branch = optional(string, "main")
|
||||
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)
|
||||
merge_type = optional(string, "squash")
|
||||
delete_branch_on_merge = optional(bool, true)
|
||||
auto_init = optional(bool, true)
|
||||
branch_protection = optional(bool)
|
||||
required_checks = optional(list(string), [])
|
||||
rulesets = optional(list(string), [])
|
||||
}))
|
||||
default = {}
|
||||
|
||||
validation {
|
||||
condition = alltrue([for repo in var.repository : contains(["squash", "merge", "rebase"], repo.merge_type)])
|
||||
error_message = "merge_type must be squash, merge or rebase: ${join(", ", [for name, repo in var.repository : name if !contains(["squash", "merge", "rebase"], repo.merge_type)])}."
|
||||
}
|
||||
|
||||
validation {
|
||||
condition = alltrue([for repo in var.repository : !(repo.private && coalesce(repo.branch_protection, false))])
|
||||
error_message = "branch_protection is not enforced on private repositories on the GitHub free plan: ${join(", ", [for name, repo in var.repository : name if repo.private && coalesce(repo.branch_protection, false)])}."
|
||||
}
|
||||
|
||||
validation {
|
||||
condition = alltrue([for repo in var.repository : !(repo.private && length(repo.required_checks) > 0)])
|
||||
error_message = "required_checks are not enforced on private repositories on the GitHub free plan: ${join(", ", [for name, repo in var.repository : name if repo.private && length(repo.required_checks) > 0])}."
|
||||
}
|
||||
|
||||
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])}."
|
||||
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 {
|
||||
|
||||
Reference in New Issue
Block a user