reject private on forks and document fork_from public-upstream constraint
ci/woodpecker/pr/pre-commit Pipeline was successful
ci/woodpecker/pr/plan Pipeline was successful

This commit is contained in:
2026-11-19 22:28:01 +11:00
parent 361f34d820
commit bab6233613
3 changed files with 19 additions and 5 deletions
+4 -4
View File
@@ -96,7 +96,7 @@ variable "ruleset" {
}
variable "repository" {
description = "Map of repositories to create, keyed by name"
description = "Map of repositories to create, keyed by name; fork_from (owner/repo) forks a public upstream and requires private to be omitted"
type = map(object({
name = string
description = optional(string, "")
@@ -114,12 +114,12 @@ variable "repository" {
validation {
condition = alltrue([for repo in var.repository : repo.fork_from == null || can(regex("^[^/]+/[^/]+$", repo.fork_from))])
error_message = "fork_from must be \"<owner>/<repo>\": ${join(", ", [for name, repo in var.repository : name if repo.fork_from != null && !can(regex("^[^/]+/[^/]+$", coalesce(repo.fork_from, "-")))])}."
error_message = "fork_from must be \"<owner>/<repo>\" of a public upstream: ${join(", ", [for name, repo in var.repository : name if repo.fork_from != null && !can(regex("^[^/]+/[^/]+$", coalesce(repo.fork_from, "-")))])}."
}
validation {
condition = alltrue([for repo in var.repository : !(repo.fork_from != null && repo.private == true)])
error_message = "private cannot be set on a fork, its visibility follows the source: ${join(", ", [for name, repo in var.repository : name if repo.fork_from != null && repo.private == true])}."
condition = alltrue([for repo in var.repository : repo.fork_from == null || repo.private == null])
error_message = "private cannot be set on a fork, its visibility follows the source and only public upstreams can be forked: ${join(", ", [for name, repo in var.repository : name if repo.fork_from != null && repo.private != null])}."
}
validation {