archive github repos on destroy, reject unknown rulesets
This commit is contained in:
@@ -50,6 +50,7 @@ resource "github_repository" "this" {
|
||||
allow_rebase_merge = each.value.allow_rebase_merge
|
||||
delete_branch_on_merge = each.value.delete_branch_on_merge
|
||||
auto_init = each.value.auto_init
|
||||
archive_on_destroy = true
|
||||
}
|
||||
|
||||
resource "github_branch_default" "this" {
|
||||
|
||||
@@ -65,3 +65,15 @@ run "private_repo_with_ruleset_rejected" {
|
||||
|
||||
expect_failures = [var.repository]
|
||||
}
|
||||
|
||||
run "unknown_ruleset_rejected" {
|
||||
command = plan
|
||||
|
||||
variables {
|
||||
repository = {
|
||||
public = { name = "public", private = false, rulesets = ["missing"] }
|
||||
}
|
||||
}
|
||||
|
||||
expect_failures = [var.repository]
|
||||
}
|
||||
|
||||
@@ -71,4 +71,9 @@ variable "repository" {
|
||||
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)]])))}."
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user