Import pre-existing Gitea branch protections #61

Merged
benvin merged 1 commits from benvin/imports-branch-protection into main 2026-08-09 12:01:51 +10:00
Owner

Why

  • tofu apply fails with Error: Branch protection already exist because the nine repos protected in #60 already have live branch protection in Gitea that is absent from Terraform state, so Terraform tries to create rules that already exist and Gitea rejects them.
  • The pinned go-gitea/gitea provider 0.7.0 defines no importer for gitea_repository_branch_protection (// TODO: importer ?), so the existing rules cannot be adopted on that version.

How

  • Bump the gitea provider from 0.7.0 to 0.8.1, which adds an importer for gitea_repository_branch_protection (id format <org>/<repo>/<rule_name>).
  • Add import blocks adopting the nine existing branch protections into state instead of recreating them: app-sudaporn-research-individual, app-sudaporn-research-normalised, docker-template, puppetapi, rpmbuild-internal-ca-certificates (master); benvin-utils, container-devcompute, initbuilder, streamstack (main).
## Why - tofu apply fails with `Error: Branch protection already exist` because the nine repos protected in #60 already have live branch protection in Gitea that is absent from Terraform state, so Terraform tries to create rules that already exist and Gitea rejects them. - The pinned go-gitea/gitea provider 0.7.0 defines no importer for `gitea_repository_branch_protection` (`// TODO: importer ?`), so the existing rules cannot be adopted on that version. ## How - Bump the gitea provider from 0.7.0 to 0.8.1, which adds an importer for `gitea_repository_branch_protection` (id format `<org>/<repo>/<rule_name>`). - Add import blocks adopting the nine existing branch protections into state instead of recreating them: app-sudaporn-research-individual, app-sudaporn-research-normalised, docker-template, puppetapi, rpmbuild-internal-ca-certificates (master); benvin-utils, container-devcompute, initbuilder, streamstack (main).
unkinben added 1 commit 2026-08-09 11:45:52 +10:00
Import pre-existing Gitea branch protections
ci/woodpecker/pr/plan Pipeline was successful
ci/woodpecker/pr/pre-commit Pipeline was successful
a43267532a
Why:
- tofu apply fails with "Branch protection already exist" because the nine
  repos protected in #60 already have live branch protection in Gitea that is
  absent from Terraform state, so Terraform tries to create rules that already
  exist and Gitea rejects them.
- The pinned go-gitea/gitea provider 0.7.0 defines no importer for
  gitea_repository_branch_protection, so the existing rules cannot be adopted
  on that version.

How:
- Bump the gitea provider from 0.7.0 to 0.8.1, which adds an importer for
  gitea_repository_branch_protection (id format <org>/<repo>/<rule_name>).
- Add import blocks adopting the nine existing branch protections into state
  instead of recreating them.
benvin merged commit 15978c486f into main 2026-08-09 12:01:51 +10:00
benvin deleted branch benvin/imports-branch-protection 2026-08-09 12:01:52 +10:00
Sign in to join this conversation.