Add declarative fork support to repository config #96

Merged
benvin merged 2 commits from benvin/gitea-fork-from into main 2026-09-19 16:13:07 +10:00
2 changed files with 14 additions and 0 deletions
Showing only changes of commit 8bc04e2c7d - Show all commits
@@ -45,6 +45,7 @@ moved {
to = gitea_repository.this[0]
}
# gitea_fork has no archive_on_destroy, so removing a fork from the config deletes the repository instead of archiving it.
resource "gitea_fork" "this" {
count = var.fork_from == null ? 0 : 1
+13
View File
@@ -45,6 +45,19 @@ variable "repository" {
migration_releases = optional(bool)
}))
default = {}
validation {
condition = alltrue([
for key, repo in var.repository :
length([for attribute, value in repo : attribute if value != null && !contains(["name", "organisation", "fork_from"], attribute)]) == 0
if repo.fork_from != null
])
error_message = "gitea_fork only takes the source repository and the owning organisation, so fork_from cannot be combined with other repository settings: ${join("; ", [
for key, repo in var.repository :
"${key} also sets ${join(", ", [for attribute, value in repo : attribute if value != null && !contains(["name", "organisation", "fork_from"], attribute)])}"
if repo.fork_from != null && length([for attribute, value in repo : attribute if value != null && !contains(["name", "organisation", "fork_from"], attribute)]) > 0
])}."
}
}
variable "branch_protection" {