diff --git a/README.md b/README.md index 401d911..7d48bbf 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ members: [] ```yaml description: "" -private: true +private: null # null = private; must be omitted with fork_from default_branch: main maintainers: [] # users or @team: maintain access, seed initial .github/CODEOWNERS codeowners: [] # push access @@ -42,8 +42,11 @@ merge_type: squash # squash | merge | rebase delete_branch_on_merge: true rulesets: [] # opt-in rulesets from ruleset/ exclude_rulesets: [] # opt out of non-mandatory all_repos rulesets +fork_from: null # owner/repo: fork a public upstream (see below) ``` +`fork_from: owner/repo` creates the repository as a fork of a public upstream. Visibility follows the source, so `private` must be omitted. `default_branch` must match the upstream default branch. `fork_from` only works when creating a new repository: the old one is archived on destroy and keeps the name, so to convert an existing repository delete it on GitHub (or `terragrunt state rm` its repository resources) first. + `ruleset/.yaml`: ```yaml diff --git a/config/git.unkin.net/unkin/repository/golib.yaml b/config/git.unkin.net/unkin/repository/golib.yaml index 8dae4b6..9bdbdd3 100644 --- a/config/git.unkin.net/unkin/repository/golib.yaml +++ b/config/git.unkin.net/unkin/repository/golib.yaml @@ -2,6 +2,7 @@ description: "Shared Go library for estate services: postgres, http service kit, private: false default_branch: "main" default_delete_branch_after_merge: true +archived: true default_merge_style: "squash" branch_protection: - rule_name: "main" diff --git a/config/git.unkin.net/unkin/repository/terraform-provider-artifactapi.yaml b/config/git.unkin.net/unkin/repository/terraform-provider-artifactapi.yaml index d8f1fb4..6442fb0 100644 --- a/config/git.unkin.net/unkin/repository/terraform-provider-artifactapi.yaml +++ b/config/git.unkin.net/unkin/repository/terraform-provider-artifactapi.yaml @@ -1,6 +1,7 @@ description: "Terraform provider for managing ArtifactAPI" private: false default_delete_branch_after_merge: true +archived: true branch_protection: - rule_name: "main" merge_whitelist_teams: diff --git a/config/git.unkin.net/unkin/repository/terraform-provider-encapi.yaml b/config/git.unkin.net/unkin/repository/terraform-provider-encapi.yaml index 13f3bf3..42ccec1 100644 --- a/config/git.unkin.net/unkin/repository/terraform-provider-encapi.yaml +++ b/config/git.unkin.net/unkin/repository/terraform-provider-encapi.yaml @@ -2,6 +2,7 @@ description: "Terraform provider for encapi: manage Puppet ENC roles, statuses, private: false default_branch: "main" default_delete_branch_after_merge: true +archived: true default_merge_style: "squash" branch_protection: - rule_name: "main" diff --git a/config/git.unkin.net/unkin/repository/terraform-provider-giteavaultsecret.yaml b/config/git.unkin.net/unkin/repository/terraform-provider-giteavaultsecret.yaml index f0fac71..ef27317 100644 --- a/config/git.unkin.net/unkin/repository/terraform-provider-giteavaultsecret.yaml +++ b/config/git.unkin.net/unkin/repository/terraform-provider-giteavaultsecret.yaml @@ -2,6 +2,7 @@ description: "Terraform provider for the Vault/OpenBao Gitea token secrets engin private: false default_branch: "main" default_delete_branch_after_merge: true +archived: true # Squash-only: the gitea provider has no "default merge style", so we restrict # the allowed styles to squash to force it. allow_merge_commits: false diff --git a/config/git.unkin.net/unkin/repository/terraform-provider-gpgvaultsecret.yaml b/config/git.unkin.net/unkin/repository/terraform-provider-gpgvaultsecret.yaml index bc81928..8086fae 100644 --- a/config/git.unkin.net/unkin/repository/terraform-provider-gpgvaultsecret.yaml +++ b/config/git.unkin.net/unkin/repository/terraform-provider-gpgvaultsecret.yaml @@ -2,6 +2,7 @@ description: "Terraform provider for the Vault/OpenBao GPG/OpenPGP secrets engin private: false default_branch: "main" default_delete_branch_after_merge: true +archived: true # Squash-only: the gitea provider has no "default merge style", so we restrict # the allowed styles to squash to force it. allow_merge_commits: false diff --git a/config/git.unkin.net/unkin/repository/terraform-provider-kea.yaml b/config/git.unkin.net/unkin/repository/terraform-provider-kea.yaml index d44a26a..f1e57dd 100644 --- a/config/git.unkin.net/unkin/repository/terraform-provider-kea.yaml +++ b/config/git.unkin.net/unkin/repository/terraform-provider-kea.yaml @@ -2,6 +2,7 @@ description: "Terraform provider for the kea-operator KeaAPI: manage Kea DHCP su private: false default_branch: "main" default_delete_branch_after_merge: true +archived: true default_merge_style: "squash" branch_protection: - rule_name: "main" diff --git a/config/git.unkin.net/unkin/repository/terraform-provider-litellmvaultsecret.yaml b/config/git.unkin.net/unkin/repository/terraform-provider-litellmvaultsecret.yaml index c16652b..b2df6bf 100644 --- a/config/git.unkin.net/unkin/repository/terraform-provider-litellmvaultsecret.yaml +++ b/config/git.unkin.net/unkin/repository/terraform-provider-litellmvaultsecret.yaml @@ -2,6 +2,7 @@ description: "Terraform provider for the Vault/OpenBao LiteLLM dynamic secrets e private: false default_branch: "main" default_delete_branch_after_merge: true +archived: true # Squash-only: the gitea provider has no "default merge style", so we restrict # the allowed styles to squash to force it. allow_merge_commits: false diff --git a/config/git.unkin.net/unkin/repository/terraform-provider-ranchervaultsecret.yaml b/config/git.unkin.net/unkin/repository/terraform-provider-ranchervaultsecret.yaml index 5b7e5f0..c1dccdb 100644 --- a/config/git.unkin.net/unkin/repository/terraform-provider-ranchervaultsecret.yaml +++ b/config/git.unkin.net/unkin/repository/terraform-provider-ranchervaultsecret.yaml @@ -2,6 +2,7 @@ description: "Terraform provider for the Vault/OpenBao Rancher token secrets eng private: false default_branch: "main" default_delete_branch_after_merge: true +archived: true # Squash-only: the gitea provider has no "default merge style", so we restrict # the allowed styles to squash to force it. allow_merge_commits: false diff --git a/config/git.unkin.net/unkin/repository/terraform-provider-vault-secrets-arrstack.yaml b/config/git.unkin.net/unkin/repository/terraform-provider-vault-secrets-arrstack.yaml index e31e17e..282f136 100644 --- a/config/git.unkin.net/unkin/repository/terraform-provider-vault-secrets-arrstack.yaml +++ b/config/git.unkin.net/unkin/repository/terraform-provider-vault-secrets-arrstack.yaml @@ -2,6 +2,7 @@ description: "Terraform provider to manage the arrstack Vault secrets engine (co private: false default_branch: "main" default_delete_branch_after_merge: true +archived: true # Squash-only: the gitea provider has no "default merge style", so we restrict # the allowed styles to squash to force it. allow_merge_commits: false diff --git a/config/git.unkin.net/unkin/repository/terraform-provider-vault-secrets-netbox.yaml b/config/git.unkin.net/unkin/repository/terraform-provider-vault-secrets-netbox.yaml index 63ff875..9bcfc04 100644 --- a/config/git.unkin.net/unkin/repository/terraform-provider-vault-secrets-netbox.yaml +++ b/config/git.unkin.net/unkin/repository/terraform-provider-vault-secrets-netbox.yaml @@ -2,6 +2,7 @@ description: "Terraform provider for the Vault/OpenBao NetBox token secrets engi private: false default_branch: "main" default_delete_branch_after_merge: true +archived: true # Squash-only: the gitea provider has no "default merge style", so we restrict # the allowed styles to squash to force it. allow_merge_commits: false diff --git a/config/git.unkin.net/unkin/repository/vault-plugin-secrets-apptoken.yaml b/config/git.unkin.net/unkin/repository/vault-plugin-secrets-apptoken.yaml index 56cc968..670953d 100644 --- a/config/git.unkin.net/unkin/repository/vault-plugin-secrets-apptoken.yaml +++ b/config/git.unkin.net/unkin/repository/vault-plugin-secrets-apptoken.yaml @@ -2,6 +2,7 @@ description: "HashiCorp Vault / OpenBao secrets engine issuing short-lived signe private: false default_branch: "main" default_delete_branch_after_merge: true +archived: true # Squash-only: the gitea provider has no "default merge style", so we restrict # the allowed styles to squash to force it. allow_merge_commits: false diff --git a/config/github.com/IUCLabs/repository/terraform-provider-vault-secrets-ghp.yaml b/config/github.com/IUCLabs/repository/terraform-provider-vault-secrets-ghp.yaml index 4fc6833..f3a4449 100644 --- a/config/github.com/IUCLabs/repository/terraform-provider-vault-secrets-ghp.yaml +++ b/config/github.com/IUCLabs/repository/terraform-provider-vault-secrets-ghp.yaml @@ -1,4 +1,4 @@ -description: "Terraform provider for the Vault/OpenBao ghp token secrets engine (vault-secrets-ghp)" +description: "Terraform provider for the Vault/OpenBao goodtune/ghp token secrets engine (vault-secrets-ghp)" private: true maintainers: - "@maintainers" diff --git a/config/github.com/IUCLabs/repository/vault-plugin-secrets-ghp.yaml b/config/github.com/IUCLabs/repository/vault-plugin-secrets-ghp.yaml index d8eb632..db71c99 100644 --- a/config/github.com/IUCLabs/repository/vault-plugin-secrets-ghp.yaml +++ b/config/github.com/IUCLabs/repository/vault-plugin-secrets-ghp.yaml @@ -1,4 +1,4 @@ -description: "HashiCorp Vault / OpenBao secrets engine for ghp: mints ephemeral, scoped access tokens via the ghp admin API, authenticating as a static admin service token" +description: "HashiCorp Vault / OpenBao secrets engine for goodtune/ghp: mints ephemeral, scoped access tokens via the ghp admin API, authenticating as a static admin service token" private: true maintainers: - "@maintainers" diff --git a/modules/github_org/tests/github_org.tftest.hcl b/modules/github_org/tests/github_org.tftest.hcl index 1b72dc2..ef329fc 100644 --- a/modules/github_org/tests/github_org.tftest.hcl +++ b/modules/github_org/tests/github_org.tftest.hcl @@ -119,7 +119,6 @@ run "fork_from_source" { autocraft = { name = "autocraft", fork_from = "storytold/autocraft", maintainers = ["@maintainers"] } plain = { name = "plain" } secret = { name = "secret", maintainers = ["@maintainers"] } - public = { name = "public", private = false, fork_from = "storytold/public" } } } @@ -176,6 +175,18 @@ run "private_fork_rejected" { expect_failures = [var.repository] } +run "public_fork_rejected" { + command = plan + + variables { + repository = { + bad = { name = "bad", fork_from = "storytold/autocraft", private = false } + } + } + + expect_failures = [var.repository] +} + run "invalid_fork_from_rejected" { command = plan diff --git a/modules/github_org/variables.tf b/modules/github_org/variables.tf index e6f6cca..95297bd 100644 --- a/modules/github_org/variables.tf +++ b/modules/github_org/variables.tf @@ -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 \"/\": ${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 \"/\" 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 {