Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle repo rename edge case for team repository deletions #870

Merged
merged 1 commit into from
Sep 2, 2021

Conversation

k24dizzle
Copy link
Contributor

@k24dizzle k24dizzle commented Aug 3, 2021

There is an apply error that can happen occasionally when you have a plan that:

  • Renames a github_repository
  • Destroys and attempts to recreate the associated github_team_repository's to connect to the new repo name.

Most times, such a plan works:

  1. Destroy github_team_repository's connected to the repo
  2. Rename the github_repository
  3. Recreate the github_team_repository's under the repo's new name

However, sometimes, steps 1 and 2 overlap in which case you'll get a 404 when you try to destroy a github_team_repository that is connected to a repo that has just been renamed.

This GIST contains a sample plan and apply of this edge case:
https://gist.github.com/k24dizzle/36fbc3921c7a074168bee287263df02b

See this repo for example tf config that could run into this error: https://github.com/kzhaotest/team_repo_edge_case

This PR takes advantage of a quirk of the github API to fix this edge case. If you try to get a repo that has just been renamed, you can still access it via the API under the old name, to get the new name of the repo. Then you can use the new name to delete the github_team_repository.

@k24dizzle
Copy link
Contributor Author

@jcudit would really appreciate a review on this PR :)

@jcudit jcudit modified the milestones: v4.15.0, v4.14.0 Aug 10, 2021
@k24dizzle
Copy link
Contributor Author

k24dizzle commented Aug 25, 2021

@jcudit any update for this one? 👀

@jcudit jcudit merged commit 4902101 into integrations:main Sep 2, 2021
@jcudit
Copy link
Contributor

jcudit commented Sep 2, 2021

Thanks for getting this written out and patched up!

kfcampbell pushed a commit to kfcampbell/terraform-provider-github that referenced this pull request Jul 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants