reject private on forks and document fork_from public-upstream constraint
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user