From d34f4a2f4f97621a3efb9184e874c7706aa5bcb9 Mon Sep 17 00:00:00 2001 From: Steve Loeppky Date: Mon, 30 Nov 2026 13:57:15 -0800 Subject: [PATCH 1/4] Check repository permissions at plan time GitHub only accepts pull, triage, push, maintain, admin, or a custom repository role as a collaborator or team permission, and the provider does not validate it. A config using the UI role name (e.g. write) planned cleanly and failed with 422 on apply. Add preconditions on github_repository_collaborator and github_team_repository so plan fails with the YAML path, a hint for read/write, and the list of valid permissions. Custom roles can be declared in local.custom_repository_roles. --- CHANGELOG.md | 1 + docs/EXAMPLE.yml | 4 ++-- terraform/locals.tf | 9 +++++++++ terraform/resources.tf | 12 ++++++++++++ 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5549e1d..d21eeab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - shared action for adding a label to all repositories - issue_label support - new args for repositories and branch protection rules +- plan-time check that repository collaborator and team permissions are ones GitHub accepts (`pull`, `triage`, `push`, `maintain`, `admin`, or a role listed in `custom_repository_roles` in `locals_override.tf`), with a hint when the GitHub UI role name (`read`, `write`) is used ### Changed - workflows: added separate GitHub Actions environments for reading organization state, writing organization state, and pushing repository changes diff --git a/docs/EXAMPLE.yml b/docs/EXAMPLE.yml index b4c6c1e..771e910 100644 --- a/docs/EXAMPLE.yml +++ b/docs/EXAMPLE.yml @@ -44,7 +44,7 @@ repositories: # This group defines repositories (https://registry.terraform.io/p contexts: - Comment strict: true - collaborators: # This group defines repository collaborators (https://registry.terraform.io/providers/integrations/github/latest/docs/resources/repository_collaborator) + collaborators: # This group defines repository collaborators (https://registry.terraform.io/providers/integrations/github/latest/docs/resources/repository_collaborator); keys are API permission names, so use pull for Read and push for Write admin: # This array defines repository collaborators with permission=admin - peter maintain: # This array defines repository collaborators with permission=maintain @@ -52,7 +52,7 @@ repositories: # This group defines repositories (https://registry.terraform.io/p push: [] # This array defines repository collaborators with permission=push triage: [] # This array defines repository collaborators with permission=triage pull: [] # This array defines repository collaborators with permission=pull - teams: # This group defines teams with access to the repository (https://registry.terraform.io/providers/integrations/github/latest/docs/resources/team_repository) + teams: # This group defines teams with access to the repository (https://registry.terraform.io/providers/integrations/github/latest/docs/resources/team_repository); keys are API permission names, so use pull for Read and push for Write admin: [] # This array defines teams with permission=admin maintain: [] # This array defines teams with permission=maintain push: # This array defines teams with permission=push diff --git a/terraform/locals.tf b/terraform/locals.tf index c05d3aa..1c01c94 100644 --- a/terraform/locals.tf +++ b/terraform/locals.tf @@ -4,6 +4,15 @@ locals { advanced_security = false config = yamldecode(file("${path.module}/../github/${local.organization}.yml")) state = jsondecode(file("${path.module}/${local.organization}.tfstate.json")) + # Names of the organization's custom repository roles that collaborators and teams can be granted, in addition to GitHub's built-in roles. + custom_repository_roles = [] + # GitHub's built-in roles, by API name: Read is pull and Write is push. + repository_permissions = concat(["pull", "triage", "push", "maintain", "admin"], local.custom_repository_roles) + # Role names from the GitHub UI that people often write instead of the API name. + repository_permission_hints = { + "read" = "pull" + "write" = "push" + } ignore = { "repositories" = [] "teams" = [] diff --git a/terraform/resources.tf b/terraform/resources.tf index 73a03cb..ad611c3 100644 --- a/terraform/resources.tf +++ b/terraform/resources.tf @@ -112,6 +112,12 @@ resource "github_repository_collaborator" "this" { lifecycle { ignore_changes = [] + + # Resources imported through var.resources come from GitHub, so only the YAML config is checked. + precondition { + condition = var.resources != null || contains(local.repository_permissions, each.value.permission) + error_message = "repositories.${each.value.repository}.collaborators.${each.value.permission} in github/${local.organization}.yml: \"${each.value.permission}\" is not a repository permission GitHub accepts, so granting it to collaborator \"${each.value.username}\" would fail on apply.${contains(keys(local.repository_permission_hints), each.value.permission) ? " Use \"${local.repository_permission_hints[each.value.permission]}\" instead." : ""} Valid permissions: ${join(", ", local.repository_permissions)}. To use a custom repository role, add it to local.custom_repository_roles in terraform/locals_override.tf." + } } } @@ -188,6 +194,12 @@ resource "github_team_repository" "this" { lifecycle { ignore_changes = [] + + # Resources imported through var.resources come from GitHub, so only the YAML config is checked. + precondition { + condition = var.resources != null || contains(local.repository_permissions, each.value.permission) + error_message = "repositories.${each.value.repository}.teams.${each.value.permission} in github/${local.organization}.yml: \"${each.value.permission}\" is not a repository permission GitHub accepts, so granting it to team \"${each.value.team}\" would fail on apply.${contains(keys(local.repository_permission_hints), each.value.permission) ? " Use \"${local.repository_permission_hints[each.value.permission]}\" instead." : ""} Valid permissions: ${join(", ", local.repository_permissions)}. To use a custom repository role, add it to local.custom_repository_roles in terraform/locals_override.tf." + } } } From 63f56122a75931927cbf7a5fdcfc5885b2a5c5e3 Mon Sep 17 00:00:00 2001 From: Steve Loeppky Date: Mon, 30 Nov 2026 14:02:50 -0800 Subject: [PATCH 2/4] Fix archived team grants, allow moderate, clarify permission errors Team grants on archived repositories come from Terraform state, which has team_id but no team attribute, so the error message expression broke the plan. Fall back to team_id (and the resource key for collaborators). Add GitHub's built-in moderate role, reword the error so it does not claim GitHub will reject a custom role that is merely undeclared, and note the custom role upgrade step in the CHANGELOG. --- CHANGELOG.md | 3 ++- terraform/locals.tf | 6 +++--- terraform/resources.tf | 8 ++++---- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d21eeab..a6f416a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,9 +21,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - shared action for adding a label to all repositories - issue_label support - new args for repositories and branch protection rules -- plan-time check that repository collaborator and team permissions are ones GitHub accepts (`pull`, `triage`, `push`, `maintain`, `admin`, or a role listed in `custom_repository_roles` in `locals_override.tf`), with a hint when the GitHub UI role name (`read`, `write`) is used +- plan-time check that repository collaborator and team permissions are GitHub built-in roles (`pull`, `triage`, `moderate`, `push`, `maintain`, `admin`) or custom roles listed in `custom_repository_roles`, with a hint when a GitHub UI role name (`read`, `write`) is used ### Changed +- **BREAKING**: if your YAML grants custom repository roles to collaborators or teams, list them in `custom_repository_roles` in `terraform/locals_override.tf` before upgrading, or plans will fail (the Plan workflow uses the base branch's Terraform files, so merge the `locals_override.tf` change before any PR that grants a new custom role) - workflows: added separate GitHub Actions environments for reading organization state, writing organization state, and pushing repository changes - workflows: pin third-party actions to latest release SHAs and replan from the merged commit before applying - docs: update template repository references from `github-mgmt-template` to `github-as-code` diff --git a/terraform/locals.tf b/terraform/locals.tf index 1c01c94..6650d24 100644 --- a/terraform/locals.tf +++ b/terraform/locals.tf @@ -4,10 +4,10 @@ locals { advanced_security = false config = yamldecode(file("${path.module}/../github/${local.organization}.yml")) state = jsondecode(file("${path.module}/${local.organization}.tfstate.json")) - # Names of the organization's custom repository roles that collaborators and teams can be granted, in addition to GitHub's built-in roles. + # Custom repository roles already created in the GitHub organization that collaborators and teams can be granted, in addition to GitHub's built-in roles. custom_repository_roles = [] - # GitHub's built-in roles, by API name: Read is pull and Write is push. - repository_permissions = concat(["pull", "triage", "push", "maintain", "admin"], local.custom_repository_roles) + # GitHub's built-in repository roles by API name (Read is pull, Write is push), followed by the custom ones. + repository_permissions = concat(["pull", "triage", "moderate", "push", "maintain", "admin"], local.custom_repository_roles) # Role names from the GitHub UI that people often write instead of the API name. repository_permission_hints = { "read" = "pull" diff --git a/terraform/resources.tf b/terraform/resources.tf index ad611c3..63520cf 100644 --- a/terraform/resources.tf +++ b/terraform/resources.tf @@ -113,10 +113,10 @@ resource "github_repository_collaborator" "this" { lifecycle { ignore_changes = [] - # Resources imported through var.resources come from GitHub, so only the YAML config is checked. + # var.resources is only set by the sync script's terraform import, which has no YAML permission to check. precondition { condition = var.resources != null || contains(local.repository_permissions, each.value.permission) - error_message = "repositories.${each.value.repository}.collaborators.${each.value.permission} in github/${local.organization}.yml: \"${each.value.permission}\" is not a repository permission GitHub accepts, so granting it to collaborator \"${each.value.username}\" would fail on apply.${contains(keys(local.repository_permission_hints), each.value.permission) ? " Use \"${local.repository_permission_hints[each.value.permission]}\" instead." : ""} Valid permissions: ${join(", ", local.repository_permissions)}. To use a custom repository role, add it to local.custom_repository_roles in terraform/locals_override.tf." + error_message = "repositories.${each.value.repository}.collaborators.${each.value.permission} in github/${local.organization}.yml: \"${each.value.permission}\" (granted to collaborator \"${try(each.value.username, each.key)}\") is not a repository permission this configuration allows.${contains(keys(local.repository_permission_hints), each.value.permission) ? " Use \"${local.repository_permission_hints[each.value.permission]}\" instead." : ""} Valid permissions: ${join(", ", local.repository_permissions)}. To use a custom repository role that exists in GitHub, add it to local.custom_repository_roles in terraform/locals_override.tf." } } } @@ -195,10 +195,10 @@ resource "github_team_repository" "this" { lifecycle { ignore_changes = [] - # Resources imported through var.resources come from GitHub, so only the YAML config is checked. + # var.resources is only set by the sync script's terraform import, which has no YAML permission to check. precondition { condition = var.resources != null || contains(local.repository_permissions, each.value.permission) - error_message = "repositories.${each.value.repository}.teams.${each.value.permission} in github/${local.organization}.yml: \"${each.value.permission}\" is not a repository permission GitHub accepts, so granting it to team \"${each.value.team}\" would fail on apply.${contains(keys(local.repository_permission_hints), each.value.permission) ? " Use \"${local.repository_permission_hints[each.value.permission]}\" instead." : ""} Valid permissions: ${join(", ", local.repository_permissions)}. To use a custom repository role, add it to local.custom_repository_roles in terraform/locals_override.tf." + error_message = "repositories.${each.value.repository}.teams.${each.value.permission} in github/${local.organization}.yml: \"${each.value.permission}\" (granted to team \"${try(each.value.team, each.value.team_id)}\") is not a repository permission this configuration allows.${contains(keys(local.repository_permission_hints), each.value.permission) ? " Use \"${local.repository_permission_hints[each.value.permission]}\" instead." : ""} Valid permissions: ${join(", ", local.repository_permissions)}. To use a custom repository role that exists in GitHub, add it to local.custom_repository_roles in terraform/locals_override.tf." } } } From a85e3ba8d7927fdf096808bfaead30ad31795acb Mon Sep 17 00:00:00 2001 From: Steve Loeppky Date: Tue, 1 Dec 2026 16:51:49 -0800 Subject: [PATCH 3/4] Add Terraform tests for repository permission checks and run them in CI terraform/tests/run.sh runs each tests/.tftest.hcl against a scratch copy of the module with that case's YAML fixture (and optional state and override files) and a mocked GitHub provider. Cases cover every built-in permission, grants on archived repositories read from state, GitHub UI role names, and declared and undeclared custom roles. The Test workflow runs terraform fmt -check and these tests on pull requests and pushes that touch terraform/. --- .github/workflows/test.yml | 43 +++++++++++++++++++ CHANGELOG.md | 1 + .../repository_permissions_custom_role.yml | 8 ++++ ...sitory_permissions_custom_role_override.tf | 3 ++ .../repository_permissions_ui_names.yml | 8 ++++ ...ory_permissions_undeclared_custom_role.yml | 8 ++++ .../fixtures/repository_permissions_valid.yml | 25 +++++++++++ ...ository_permissions_custom_role.tftest.hcl | 7 +++ ...repository_permissions_ui_names.tftest.hcl | 12 ++++++ ...missions_undeclared_custom_role.tftest.hcl | 12 ++++++ .../repository_permissions_valid.tftest.hcl | 18 ++++++++ terraform/tests/run.sh | 35 +++++++++++++++ 12 files changed, 180 insertions(+) create mode 100644 .github/workflows/test.yml create mode 100644 terraform/tests/fixtures/repository_permissions_custom_role.yml create mode 100644 terraform/tests/fixtures/repository_permissions_custom_role_override.tf create mode 100644 terraform/tests/fixtures/repository_permissions_ui_names.yml create mode 100644 terraform/tests/fixtures/repository_permissions_undeclared_custom_role.yml create mode 100644 terraform/tests/fixtures/repository_permissions_valid.yml create mode 100644 terraform/tests/repository_permissions_custom_role.tftest.hcl create mode 100644 terraform/tests/repository_permissions_ui_names.tftest.hcl create mode 100644 terraform/tests/repository_permissions_undeclared_custom_role.tftest.hcl create mode 100644 terraform/tests/repository_permissions_valid.tftest.hcl create mode 100755 terraform/tests/run.sh diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..3ccd18d --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,43 @@ +name: Test + +on: + pull_request: + branches: [master] + paths: + - 'terraform/**' + - '.github/workflows/test.yml' + push: + branches: [master] + paths: + - 'terraform/**' + - '.github/workflows/test.yml' + workflow_dispatch: + +defaults: + run: + shell: bash + +concurrency: + group: test-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + terraform: + permissions: + contents: read + name: Terraform + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + persist-credentials: false + - name: Setup terraform + uses: hashicorp/setup-terraform@5e8dbf3c6d9deaf4193ca7a8fb23f2ac83bb6c85 # v4.0.0 + with: + terraform_version: 1.12.0 + terraform_wrapper: false + - name: Check terraform formatting + run: terraform fmt -check terraform terraform/tests terraform/tests/fixtures + - name: Run terraform tests + run: terraform/tests/run.sh diff --git a/CHANGELOG.md b/CHANGELOG.md index a6f416a..46bc871 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - issue_label support - new args for repositories and branch protection rules - plan-time check that repository collaborator and team permissions are GitHub built-in roles (`pull`, `triage`, `moderate`, `push`, `maintain`, `admin`) or custom roles listed in `custom_repository_roles`, with a hint when a GitHub UI role name (`read`, `write`) is used +- Test workflow that runs `terraform fmt -check` and the Terraform tests in `terraform/tests` (with a mocked GitHub provider) on changes to `terraform/` ### Changed - **BREAKING**: if your YAML grants custom repository roles to collaborators or teams, list them in `custom_repository_roles` in `terraform/locals_override.tf` before upgrading, or plans will fail (the Plan workflow uses the base branch's Terraform files, so merge the `locals_override.tf` change before any PR that grants a new custom role) diff --git a/terraform/tests/fixtures/repository_permissions_custom_role.yml b/terraform/tests/fixtures/repository_permissions_custom_role.yml new file mode 100644 index 0000000..611ad5e --- /dev/null +++ b/terraform/tests/fixtures/repository_permissions_custom_role.yml @@ -0,0 +1,8 @@ +repositories: + demo: + collaborators: + security-auditor: [alice] + teams: + security-auditor: [auditors] +teams: + auditors: {} diff --git a/terraform/tests/fixtures/repository_permissions_custom_role_override.tf b/terraform/tests/fixtures/repository_permissions_custom_role_override.tf new file mode 100644 index 0000000..f16f701 --- /dev/null +++ b/terraform/tests/fixtures/repository_permissions_custom_role_override.tf @@ -0,0 +1,3 @@ +locals { + custom_repository_roles = ["security-auditor"] +} diff --git a/terraform/tests/fixtures/repository_permissions_ui_names.yml b/terraform/tests/fixtures/repository_permissions_ui_names.yml new file mode 100644 index 0000000..706395a --- /dev/null +++ b/terraform/tests/fixtures/repository_permissions_ui_names.yml @@ -0,0 +1,8 @@ +repositories: + demo: + collaborators: + read: [alice] + teams: + write: [developers] +teams: + developers: {} diff --git a/terraform/tests/fixtures/repository_permissions_undeclared_custom_role.yml b/terraform/tests/fixtures/repository_permissions_undeclared_custom_role.yml new file mode 100644 index 0000000..611ad5e --- /dev/null +++ b/terraform/tests/fixtures/repository_permissions_undeclared_custom_role.yml @@ -0,0 +1,8 @@ +repositories: + demo: + collaborators: + security-auditor: [alice] + teams: + security-auditor: [auditors] +teams: + auditors: {} diff --git a/terraform/tests/fixtures/repository_permissions_valid.yml b/terraform/tests/fixtures/repository_permissions_valid.yml new file mode 100644 index 0000000..2566bbb --- /dev/null +++ b/terraform/tests/fixtures/repository_permissions_valid.yml @@ -0,0 +1,25 @@ +repositories: + active: + collaborators: + admin: [alice] + maintain: [bob] + moderate: [carol] + push: [dave] + triage: [erin] + pull: [frank] + teams: + admin: [admins] + maintain: [maintainers] + moderate: [moderators] + push: [developers] + triage: [triagers] + pull: [readers] + old: + archived: true +teams: + admins: {} + maintainers: {} + moderators: {} + developers: {} + triagers: {} + readers: {} diff --git a/terraform/tests/repository_permissions_custom_role.tftest.hcl b/terraform/tests/repository_permissions_custom_role.tftest.hcl new file mode 100644 index 0000000..b4379e9 --- /dev/null +++ b/terraform/tests/repository_permissions_custom_role.tftest.hcl @@ -0,0 +1,7 @@ +# A custom repository role listed in local.custom_repository_roles plans cleanly. + +mock_provider "github" {} + +run "accepts_declared_custom_role" { + command = plan +} diff --git a/terraform/tests/repository_permissions_ui_names.tftest.hcl b/terraform/tests/repository_permissions_ui_names.tftest.hcl new file mode 100644 index 0000000..1871633 --- /dev/null +++ b/terraform/tests/repository_permissions_ui_names.tftest.hcl @@ -0,0 +1,12 @@ +# GitHub UI role names (read, write) are not API permissions, so plan fails. + +mock_provider "github" {} + +run "rejects_ui_role_names" { + command = plan + + expect_failures = [ + github_repository_collaborator.this, + github_team_repository.this, + ] +} diff --git a/terraform/tests/repository_permissions_undeclared_custom_role.tftest.hcl b/terraform/tests/repository_permissions_undeclared_custom_role.tftest.hcl new file mode 100644 index 0000000..3dd368d --- /dev/null +++ b/terraform/tests/repository_permissions_undeclared_custom_role.tftest.hcl @@ -0,0 +1,12 @@ +# A custom repository role missing from local.custom_repository_roles fails plan. + +mock_provider "github" {} + +run "rejects_undeclared_custom_role" { + command = plan + + expect_failures = [ + github_repository_collaborator.this, + github_team_repository.this, + ] +} diff --git a/terraform/tests/repository_permissions_valid.tftest.hcl b/terraform/tests/repository_permissions_valid.tftest.hcl new file mode 100644 index 0000000..4f838df --- /dev/null +++ b/terraform/tests/repository_permissions_valid.tftest.hcl @@ -0,0 +1,18 @@ +# Built-in permissions in the YAML, plus grants on an archived repository that +# come from Terraform state (which has team_id but no team name), plan cleanly. + +mock_provider "github" {} + +run "accepts_builtin_permissions" { + command = plan + + assert { + condition = length(github_repository_collaborator.this) == 7 + error_message = "Expected 6 collaborators from the YAML and 1 from the archived repository's state." + } + + assert { + condition = length(github_team_repository.this) == 7 + error_message = "Expected 6 team grants from the YAML and 1 from the archived repository's state." + } +} diff --git a/terraform/tests/run.sh b/terraform/tests/run.sh new file mode 100755 index 0000000..46f20d3 --- /dev/null +++ b/terraform/tests/run.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env bash +# Runs each tests/.tftest.hcl against a scratch copy of this module whose +# github/.yml comes from tests/fixtures/.yml. A case can also +# provide tests/fixtures/.tfstate.json (state the config reads, such as +# grants on archived repositories) and tests/fixtures/_override.tf +# (copied into the module, such as extra locals). The GitHub provider is +# mocked, so no credentials or network access to GitHub are needed. +set -euo pipefail + +module="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" +work="$(mktemp -d)" +trap 'rm -rf "$work"' EXIT + +mkdir -p "$work/github" "$work/terraform" +cp "$module"/*.tf "$work/terraform/" +cp -R "$module/tests" "$work/terraform/tests" +cd "$work/terraform" +terraform init -backend=false -input=false -no-color > /dev/null + +status=0 +for test in tests/*.tftest.hcl; do + name="$(basename "$test" .tftest.hcl)" + cp "tests/fixtures/$name.yml" "../github/$name.yml" + if [[ -f "tests/fixtures/$name.tfstate.json" ]]; then + cp "tests/fixtures/$name.tfstate.json" "$name.tfstate.json" + else + echo '{}' > "$name.tfstate.json" + fi + rm -f zz_case_override.tf + if [[ -f "tests/fixtures/${name}_override.tf" ]]; then + cp "tests/fixtures/${name}_override.tf" zz_case_override.tf + fi + TF_WORKSPACE="$name" terraform test -no-color -filter="$test" || status=1 +done +exit "$status" From d0c7441cb66b3dff2380d20e580cd65b4cc87956 Mon Sep 17 00:00:00 2001 From: Steve Loeppky Date: Tue, 1 Dec 2026 16:52:39 -0800 Subject: [PATCH 4/4] Commit the archived-state test fixture as .state.json .gitignore excludes *.tfstate.*, so the fixture never reached CI. run.sh now copies tests/fixtures/.state.json into place. --- .../repository_permissions_valid.state.json | 32 +++++++++++++++++++ terraform/tests/run.sh | 6 ++-- 2 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 terraform/tests/fixtures/repository_permissions_valid.state.json diff --git a/terraform/tests/fixtures/repository_permissions_valid.state.json b/terraform/tests/fixtures/repository_permissions_valid.state.json new file mode 100644 index 0000000..7773409 --- /dev/null +++ b/terraform/tests/fixtures/repository_permissions_valid.state.json @@ -0,0 +1,32 @@ +{ + "values": { + "root_module": { + "resources": [ + { + "address": "github_repository.this[\"old\"]", + "mode": "managed", + "type": "github_repository", + "name": "this", + "index": "old", + "values": {"name": "old", "archived": true} + }, + { + "address": "github_repository_collaborator.this[\"old:grace\"]", + "mode": "managed", + "type": "github_repository_collaborator", + "name": "this", + "index": "old:grace", + "values": {"repository": "old", "username": "grace", "permission": "push"} + }, + { + "address": "github_team_repository.this[\"developers:old\"]", + "mode": "managed", + "type": "github_team_repository", + "name": "this", + "index": "developers:old", + "values": {"repository": "old", "team_id": "123", "permission": "push", "etag": ""} + } + ] + } + } +} diff --git a/terraform/tests/run.sh b/terraform/tests/run.sh index 46f20d3..c719fb2 100755 --- a/terraform/tests/run.sh +++ b/terraform/tests/run.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash # Runs each tests/.tftest.hcl against a scratch copy of this module whose # github/.yml comes from tests/fixtures/.yml. A case can also -# provide tests/fixtures/.tfstate.json (state the config reads, such as +# provide tests/fixtures/.state.json (state the config reads, such as # grants on archived repositories) and tests/fixtures/_override.tf # (copied into the module, such as extra locals). The GitHub provider is # mocked, so no credentials or network access to GitHub are needed. @@ -21,8 +21,8 @@ status=0 for test in tests/*.tftest.hcl; do name="$(basename "$test" .tftest.hcl)" cp "tests/fixtures/$name.yml" "../github/$name.yml" - if [[ -f "tests/fixtures/$name.tfstate.json" ]]; then - cp "tests/fixtures/$name.tfstate.json" "$name.tfstate.json" + if [[ -f "tests/fixtures/$name.state.json" ]]; then + cp "tests/fixtures/$name.state.json" "$name.tfstate.json" else echo '{}' > "$name.tfstate.json" fi